The commands you will actually use daily, organized by task instead of dumped alphabetically.
Device connection and management
Check connected devices
adb devices
List of devices attached
1234567890ABCDEF device
emulator-5554 device
9876543210FEDCBA unauthorized
Status meanings: device (ready), unauthorized (accept the USB debugging prompt), offline (not responding – replug USB or restart ADB), no permissions (Linux udev rules issue). adb devices -l adds model and product name, useful with multiple devices attached.
Target a specific device
With several devices connected, use -s with any command:
adb -s 1234567890ABCDEF shell getprop ro.product.model
-d targets the only USB device, -e the only emulator.
Restart the ADB server
adb kill-server
adb start-server
Fixes the majority of “device not detected” problems.
App installation and management
Install an APK
adb install path/to/app.apk
Useful flags: -r (reinstall, keep data), -d (allow downgrade), -g (grant all runtime permissions), -t (allow test APKs). Example – reinstall a debug build with all permissions:
adb install -r -g app-debug.apk
List installed packages
adb shell pm list packages
Filters: -3 (third-party), -s (system), -e (enabled), -d (disabled). Find specific apps:
adb shell pm list packages | grep chrome
Grant and revoke permissions
adb shell pm grant com.example.myapp android.permission.CAMERA
adb shell pm revoke com.example.myapp android.permission.CAMERA
File operations
Copy files to the device (push)
adb push local-file.txt /sdcard/
Common destinations: /sdcard/ (external storage), /data/local/tmp/ (temporary, world-writable), /sdcard/Download/.
Copy files from the device (pull)
adb pull /sdcard/screenshot.png
Pull to a specific location:
adb pull /sdcard/photo.jpg ~/Pictures/
Debugging and logs
Logcat
adb logcat
This floods the terminal. Filter it. Clear old logs first with adb logcat -c.
By priority (V=Verbose, D=Debug, I=Info, W=Warn, E=Error, F=Fatal):
adb logcat *:E
By app:
adb logcat | grep com.example.myapp
Save to file:
adb logcat -d > logcat.txt
Screen capture and recording
Screenshot
adb shell screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png
One-liner:
adb exec-out screencap -p > screenshot.png
Screen recording
adb shell screenrecord /sdcard/demo.mp4
Press Ctrl+C to stop, then adb pull /sdcard/demo.mp4. Options: --time-limit 30, --bit-rate 6000000, --size 1280x720.
System control
Simulate input
Type text (%s for spaces):
adb shell input text "Hello%sWorld"
Key events:
adb shell input keyevent 3 # Home
adb shell input keyevent 4 # Back
adb shell input keyevent 26 # Power
adb shell input keyevent 66 # Enter
Tap coordinates:
adb shell input tap 500 1000
Device info
adb shell getprop ro.build.version.release # Android version
adb shell getprop ro.product.model # Device model
adb shell wm size # Screen resolution
adb shell dumpsys battery # Battery status
Workflow scenarios
Quickly test an APK:
adb install -r app-debug.apk
adb shell am start -n com.example.myapp/.MainActivity
adb logcat | grep "com.example.myapp"
Debug a crash:
adb logcat -c
# reproduce the crash
adb logcat -d > crash.txt
grep -A 20 "AndroidRuntime" crash.txt
Pull a database off the device:
adb shell run-as com.example.myapp cp /data/data/com.example.myapp/databases/app.db /sdcard/
adb pull /sdcard/app.db
(run-as only works on debuggable builds.)
Troubleshooting
| Issue | Cause | Solution |
|---|---|---|
| “device unauthorized” | USB debugging prompt not accepted | Unlock device, accept prompt, check “Always allow” |
| “no devices found” | Device not detected or ADB server issue | adb kill-server && adb start-server |
| “insufficient permissions” (Linux) | udev rules not configured | Install 51-android.rules, reload udev |
| “more than one device” | Multiple devices without -s |
adb -s <serial> command |
| Logcat output overwhelming | Too many logs | Filter: adb logcat *:E or grep |
Quick reference
Most-used commands
| Command | Purpose | Example |
|---|---|---|
adb devices |
List connected devices | adb devices -l |
adb install |
Install APK | adb install -r app.apk |
adb uninstall |
Remove app | adb uninstall com.app |
adb shell |
Device shell access | adb shell ls /sdcard/ |
adb logcat |
View logs | adb logcat *:E |
adb push |
Copy to device | adb push file.txt /sdcard/ |
adb pull |
Copy from device | adb pull /sdcard/file.txt |
adb shell pm |
Package manager | pm list packages -3 |
Common keyevent codes
| Code | Key | Usage |
|---|---|---|
| 3 | Home | adb shell input keyevent 3 |
| 4 | Back | adb shell input keyevent 4 |
| 26 | Power | adb shell input keyevent 26 |
| 66 | Enter | adb shell input keyevent 66 |
| 67 | Delete (Backspace) | adb shell input keyevent 67 |
| 24/25 | Volume Up/Down | adb shell input keyevent 24 |
Important file paths
| Path | Contents |
|---|---|
/sdcard/ |
External storage root |
/sdcard/Download/ |
Downloads folder |
/data/app/ |
Installed APKs |
/data/data/<package>/ |
App’s private data |
/data/data/<package>/databases/ |
SQLite databases |
/data/local/tmp/ |
Temporary (world-writable) |
Shell tip: alias your most-used fixes, e.g. alias adbfix='adb kill-server && adb start-server' or alias logcat-error='adb logcat *:E' in ~/.bashrc.
References: Android Debug Bridge (adb) – Android Developers (developer.android.com)
Part of the series: The Complete ADB Guide — also in this series: What is ADB? · Install ADB · Wireless ADB · Troubleshooting
Was this useful?
Thanks for the feedback.
3 comments