Skip to content

Published · Updated

adb shell commands ​

In short: adb shell commands run on a connected Android phone from your computer. Run adb shell to open a command line on the phone, or adb shell followed by one command to run just that, such as adb shell pm list packages. Useful tools inside it include pm for apps, am for activities, input, getprop, settings and dumpsys.

adb shell runs commands on an Android phone from your computer. The ones you will use most are pm for apps, am to open and stop them, input for taps and typing, getprop and dumpsys for device details, and settings for system settings. None of them needs root on a phone with USB debugging on. The tables below group them by job, with an example of each.

Before the first command, turn on USB debugging and connect the phone by USB or over wireless debugging; the ADB guide shows the setup. With several phones connected, put -s and the phone's serial number from adb devices before shell.

Syntax ​

bash
adb shell                      # an interactive command line on the phone; exit or Ctrl+D leaves it
adb shell <command>            # runs one command and returns
adb -s R58M12345 shell <command>

Use the first form to explore a phone by hand and the second in scripts, where each adb shell call runs one command and returns its output and exit code.

Quoting matters: adb shell pm list packages | grep google runs grep on your computer, while adb shell "pm list packages | grep google" runs the whole line on the phone.

Apps: pm and am ​

CommandWhat it does
pm list packages -3Lists the apps you installed (-s the system apps, -d the disabled ones)
pm path com.example.appWhere the app's APK is stored, to copy it with adb pull
pm clear com.example.appClears an app's data, as Clear storage does
pm grant com.example.app android.permission.CAMERAGrants a runtime permission the app declares (pm revoke takes it back)
am start -n com.example.app/.MainActivityOpens an activity
monkey -p com.example.app -c android.intent.category.LAUNCHER 1Opens an app by its package name, as tapping its icon does
am force-stop com.example.appStops an app at once
am start -a android.intent.action.VIEW -d https://example.comOpens a web address in the default browser, or a deep link in your app

Input: taps, swipes, typing and keys ​

CommandWhat it does
input tap 540 1200Taps a point on the screen, in pixels
input swipe 540 1600 540 600 300Swipes from one point to another in 300 ms
input text hello%sworldTypes into the field that has focus (%s is a space)
input keyevent KEYCODE_HOMEPresses a key: KEYCODE_BACK, KEYCODE_WAKEUP, KEYCODE_APP_SWITCH…

wm size gives the screen's size, so you can work out the coordinates for tap and swipe.

Device details ​

CommandWhat it does
getprop ro.product.modelThe phone's model; ro.build.version.release is its Android version, ro.build.version.sdk its API level
wm size and wm densityThe screen's size in pixels and its density
dumpsys batteryBattery level, temperature and charging state
dumpsys meminfo com.example.appHow much memory an app uses
dfFree space on each storage area
cat /proc/meminfo and uptimeThe phone's memory, and how long it has been on

Settings, screen and files ​

CommandWhat it does
settings get global airplane_mode_onReads a setting from the system, secure or global table
settings put global window_animation_scale 0Turns an animation off; do the same for transition_animation_scale and animator_duration_scale to steady UI tests, as in Android app testing on real devices
svc power stayon usbKeeps the screen on while the phone is charging over USB
ls /sdcard/DownloadLists files in shared storage, where the shell user may read and write
screencap and screenrecordScreenshots and screen recordings, see adb screenshot

Which commands exist, and their options, depend on the Android version. Most print their own help, for example adb shell pm help. For am start with a deep link, extras or flags, the intent and deep link builder writes the command with the double quoting adb shell needs, and the Android permissions list has the pm grant command for each permission.

Commands that need root, and commands that erase ​

Everything above runs as Android's shell user, without root. A few things need more:

NeedsExamples
Root (a rooted phone, an emulator, or a development build after adb root)Reading another app's files in /data/data, changing files in /system, setenforce
Nothing special, but erases data with no undopm clear com.example.app, pm uninstall com.example.app, rm on files in /sdcard

Nothing in adb shell asks "are you sure?", so double-check the package name or path of an erasing command, and copy the files you want to keep first with adb pull.

Commands that only read ​

Some commands change nothing on the phone, so they are safe in a script that runs while nobody watches. BenchFleet's workflows use exactly this list by default: a workflow's shell step may run only these, with at most 32 arguments, 30 seconds and 64 KB of output, and anything else needs a separate permission that a person grants.

CommandAllowed forms
getpropAll properties, or one by name
dumpsysbattery, power, thermalservice, meminfo, cpuinfo, display, wifi, connectivity, window
pmlist packages, alone or with -3, -s, -d, -e or -f; path and a package name
settingsget from system, secure or global
wmsize, density
cat/proc/meminfo, /proc/uptime, /proc/loadavg, /proc/cpuinfo, /proc/version
uptime, date, id, whoami, df, echoAs they are

Each argument is passed on its own, so a pipe, ; or && inside one is never run as shell syntax.

On many phones at once ​

bash
for s in $(adb devices | awk 'NR>1 && $2=="device" {print $1}'); do
  echo "$s: $(adb -s "$s" shell getprop ro.build.version.release)"
done
powershell
adb devices | Select-Object -Skip 1 | ForEach-Object {
  $serial, $state = $_ -split '\s+'
  if ($state -eq 'device') { "${serial}: $(adb -s $serial shell getprop ro.build.version.release)" }
}

That prints each phone's Android version. BenchFleet shows the same details, and the battery, temperature, storage and app in front, on every phone's tile. Each phone's page also has a terminal: an interactive adb shell with the shell user's rights, one per phone, that closes after 15 minutes without input or 2 hours in all, and goes into the audit log. Logcat, APKs and a shell on many phones shows it beside the phone's log and apps, and controlling many Android phones from one PC the screen they sit on.

Free for up to 3 phones, with no account. Pro adds workflows, schedules and AI for up to 25 phones from $16 a month + VAT (including 300 cloud phone minutes every month).

Common errors and fixes ​

ErrorWhat it meansFix
/system/bin/sh: … not foundThat command does not exist on this phone's Android versionCheck the spelling, or use the command's older name
Permission deniedThe shell user may not read or change that placeUse places such as /sdcard, or a rooted test phone
adbd cannot run as root in production buildsadb root works only on emulators and development buildsUse the shell without root
error: closed or device offlineThe connection droppedReconnect; see adb devices
adb: more than one device/emulatorSeveral phones are connectedChoose one with -s and its serial number

Questions ​

What are the most useful adb shell commands?

pm list packages -3 lists the apps you installed, pm clear resets an app, am start opens an activity or a deep link, am force-stop stops an app, input tap, swipe, text and keyevent drive the screen, getprop and dumpsys battery read device details, and settings get and put read and change system settings.

What is adb shell?

It is a command line on the phone, opened from your computer through ADB. Commands typed in it run on the phone with the rights of Android's shell user, which can manage apps, settings and input but not read other apps' private data.

How do I get out of adb shell?

Type exit and press Enter, or press Ctrl+D. If a command is still running, press Ctrl+C first.

Do I need root for adb shell?

No. adb shell works on any phone with USB debugging on. Root is needed only for protected places such as other apps' data in /data; adb root works on emulators and development builds, not on retail phones.

Why does a pipe in adb shell give different results?

Without quotes, the part after the pipe runs on your computer. Put the whole command in quotes, such as adb shell "pm list packages | grep google", to run it all on the phone.

How do I open an app, type text and press buttons with adb shell?

adb shell monkey -p with the package name opens an app as its icon does, am force-stop stops it, input text types into the focused field, and input keyevent presses keys such as KEYCODE_BACK, KEYCODE_HOME and KEYCODE_POWER.

How do I check the Android version, memory and other details?

adb shell getprop ro.build.version.release gives the Android version and getprop ro.product.model the model; adb shell dumpsys meminfo shows memory, dumpsys battery the battery, and adb logcat the log.

How do I copy files between my computer and the phone?

Not from inside adb shell, which only sees the phone. Use adb push and adb pull from your computer's terminal; inside the shell, ls, cp, mv and rm manage files in shared storage such as /sdcard.

Which adb shell commands can erase data?

pm clear wipes an app's data, pm uninstall and cmd package uninstall remove an app, rm deletes files for good, and a factory reset erases the phone. Nothing in adb shell asks for confirmation first, so check the package name or path before you press Enter.

Can I run adb shell commands on many phones at once?

Each command goes to one phone, so loop over adb devices with -s and each serial number, as shown on this page. BenchFleet gives every phone a terminal on its page and runs group actions on many phones on Pro.

Which adb shell commands are safe to run without watching?

Commands that only read, such as getprop, dumpsys battery, pm list packages, settings get, wm size and df. BenchFleet's workflows allow exactly such a read-only list by default; anything that changes the phone needs a separate permission.

Start with the Free plan

Free for up to 3 phones, with no account. Pro adds workflows, schedules and AI for up to 25 phones from $16 a month + VAT (including 300 cloud phone minutes every month).