Menu

ADB Command Reference

This article introduces the commonly used adb ssh commands. You can execute adb commands in the following two ways:

  1. DuoPlus command execution interface: https://help.duoplus.net/docs/execute-the-adb-command
  2. adb client: https://help.duoplus.net/docs/adb

File Transfer

Downloading Files from a URL to a Cloud Phone

Downloading files can be time-consuming. By appending > /dev/null 2>&1 & to the command, you can execute the command in the background.

sh Copy
wget --no-check-certificate -O /sdcard/test.apk https://YOUR_APK_URL/test.apk > /dev/null 2>&1 &

Uploading Files from the Cloud Machine to a Relay Station

Uploading files can be time-consuming. By appending > /sdcard/upload.log to the command, you can write the upload progress to a log file; by appending 2>&1 & to the command, you can execute the command in the background to avoid command execution timeout.

sh Copy
curl -F "file=@/sdcard/test.apk" https://temp.sh/upload > /sdcard/upload.log 2>&1 &

After the upload is complete, use the following command to check the upload progress. If the upload is successful, you will see the file download URL in the log file:

sh Copy
cat /sdcard/upload.log

Push files from local computer to cloud device

sh Copy
# Usage
adb push [local computer file location] [cloud device file location]
# Example
adb push C:\Users\YourUsername\Documents\example.txt /sdcard/example.txt

Download files from cloud device to local computer

sh Copy
# Usage
adb pull [cloud device file location] [local computer file location]
# Example
adb pull /sdcard/example.txt C:\Users\YourUsername\Documents\

Capture screenshot of the phone screen to local computer

sh Copy
adb exec-out screencap -p > screenshot.png

Applications

Get the List of Installed Package Names

sh Copy
pm list packages -3 | cut -d ":" -f 2

Install an Application

sh Copy
pm install /sdcard/test.apk

Start an Application

sh Copy
am start -n $(dumpsys package [package_name] | grep -A 1 'MAIN' | grep '[package_name]' | sed -n 's/.*\(package_name\/[^ ]*\).*/\1/p')

Stop an Application

sh Copy
am force-stop [package_name]

Uninstall an Application

sh Copy
pm uninstall [package_name]

Clear Application Data

sh Copy
pm clear [package_name]

Grant Application Permissions

List of permission names: https://developer.android.com/reference/android/Manifest.permission#summary

sh Copy
pm grant [package_name] android.permission.[permission_name]

System Logs

Clear System Logs

sh Copy
logcat -c

Upload System Logs

sh Copy
cat logcat | nc termbin.com 9999

The returned content will include a URL containing the logcat log content.

Tip: This command can upload any text content. For example: cat /sdcard/test.txt | nc termbin.com 9999

Simulate Key Presses

General Keys

You can simulate key operations by calling input keyevent [code].

Below are some commonly used KeyEvent codes for reference:

KeyEvent Code Corresponding Key Description
4 Back Key (BACK) Simulate pressing the back button
19 Up Arrow Key (DPAD_UP) Simulate pressing the up arrow key
20 Down Arrow Key (DPAD_DOWN) Simulate pressing the down arrow key
21 Left Arrow Key (DPAD_LEFT) Simulate pressing the left arrow key
23 Select Key (DPAD_CENTER) Simulate pressing the select key (similar to confirming a click)
82 Menu Key (MENU) Open the device's menu options
24 Volume Up Key (KEYCODE_VOLUME_UP) Simulate increasing the device's volume
25 Volume Down Key (KEYCODE_VOLUME_DOWN) Simulate decreasing the device's volume

Usage Examples

bash Copy
input keyevent 19    # Up Arrow Key
input keyevent 66    # Enter Key
input keyevent 3     # Home Key

Click Coordinates

sh Copy
# Click at coordinates (500,300)
input tap 500 300
# Click at coordinates (500,300) and hold for 200ms
input swipe 500 300 500 300 200
# Swipe from coordinates (500,500) to (500,100) over a total duration of 200ms (i.e., swipe up by 400)
input swipe 500 500 500 100 200
Previous
Best Practices
Next
How to permanently enable the accessibility permission for the app.
Last modified: 2025-04-29Powered by