ADB Shell Cheat Sheet

Handy reference for `adb shell`, `pm`, `am`, file system, networking, logging and more

πŸ“Œ Important Notes

  • Prefix with adb shell: To use these commands from your computer’s terminal/command prompt, prefix with adb shell.
    adb shell pm list packages
  • Root Access: Some commands require root. If you don’t have root, commands might fail or be limited. Try adb root on emulators or permissive builds.
  • BusyBox: Availability of utilities can depend on BusyBox version and ROM.
  • Help: Use --help or -h for many commands. Example: adb shell pm --help
  • Case Sensitivity: Android shell is case-sensitive.

πŸ“¦ Package Manager (pm)

  • pm list packages – List all installed packages
  • pm list packages -f – List packages with their APK paths
  • pm list packages -d – List disabled packages
  • pm list packages -e – List enabled packages
  • pm list packages -s – List system packages
  • pm list packages -3 – List user-installed (third-party) packages
  • pm list packages <FILTER_STRING> – Filter packages by name
  • pm path <PACKAGE_NAME> – Show APK path of a package
  • pm install <PATH_TO_APK> – Install an APK
  • pm install -r <PATH_TO_APK> – Reinstall app (keep data)
  • pm install -g <PATH_TO_APK> – Install & grant all runtime permissions
  • pm uninstall <PACKAGE_NAME> – Uninstall a package
  • pm uninstall -k <PACKAGE_NAME> – Uninstall but keep data/cache
  • pm clear <PACKAGE_NAME> – Clear all app data
  • pm enable <PACKAGE_NAME> – Enable a package
  • pm disable <PACKAGE_NAME> or pm disable-user --user 0 <PACKAGE_NAME> – Disable a package
  • pm grant <PACKAGE_NAME> <PERMISSION> – Grant a runtime permission
  • pm revoke <PACKAGE_NAME> <PERMISSION> – Revoke a permission
  • pm get-install-location – Get default install location
  • pm set-install-location <0|1|2> – Set default install location (0:auto,1:internal,2:external)

🎬 Activity Manager (am)

  • am start -n <PACKAGE>/<ACTIVITY> – Start an activity
    am start -n com.android.settings/.Settings
  • am start -a <ACTION> -d <DATA_URI> -t <MIME> – Start with intent
    am start -a android.intent.action.VIEW -d http://www.google.com
  • am startservice <PACKAGE>/<SERVICE> – Start a service
  • am stopservice <PACKAGE>/<SERVICE> – Stop a service
  • am broadcast -a <ACTION> – Send a broadcast intent
  • am force-stop <PACKAGE> – Force stop app
  • am kill <PACKAGE> – Kill all processes for a package
  • am kill-all – Kill all background processes
  • am display-density <DENSITY> – Change display density
  • am display-size <WIDTHxHEIGHT> – Change display size
  • am screen-compat [on|off] <PACKAGE> – Control screen compatibility
  • am stack list – List activity stacks/tasks (newer Android)
  • am task <TASK_ID> – Show task info

πŸ“‚ File System & Navigation

  • ls, ls -a, ls -l – List files
  • cd <DIR> – Change directory
  • pwd – Print working directory
  • mkdir <DIR> – Create directory
  • rm <FILE> – Delete file
  • rm -r <DIR> – Delete directory recursively
  • rm -f <FILE> – Force delete
  • cp <SRC> <DEST> – Copy files
  • cp -r <SRC> <DEST> – Copy directories
  • mv <SRC> <DEST> – Move/rename files
  • cat <FILE> – View file contents
  • head <FILE> – View first lines
  • tail <FILE> – View last lines
  • tail -f <FILE> – Live follow file (logs)
  • touch <FILE> – Create empty file or update timestamp
  • chmod <PERMISSIONS> <FILE> – Change permissions
  • chown <OWNER>:<GROUP> <FILE> – Change owner/group
  • df – Show free space
  • du, du -h <DIR> – Show disk usage
  • find <PATH> -name "<PATTERN>" – Search files
  • grep "<PATTERN>" <FILE> – Search inside files

πŸ“Š Device Info & Settings

  • getprop – Show all system properties
  • getprop <PROPERTY> – Show a specific property
  • setprop <PROPERTY> <VALUE> – Set property (root required)
  • settings list system|global|secure – List settings
  • settings get <NAMESPACE> <SETTING> – Get setting
  • settings put <NAMESPACE> <SETTING> <VALUE> – Set setting
  • dumpsys <SERVICE> – Dump system info for a service
  • service list – List running services

🌐 Networking

  • ip addr or ifconfig – Show network interfaces
  • ip route or route -n – Show routing table
  • ping <HOST> – Ping a host
  • netstat, netstat -tulnp – Network connections/ports
  • iptables -L – List firewall rules (root)
  • svc wifi [enable|disable] – Toggle Wi-Fi
  • svc data [enable|disable] – Toggle mobile data

βš™οΈ Process Management

  • ps, ps -A, ps -ef – List processes
  • ps -T – Show threads
  • top – Live CPU/memory usage
  • kill <PID> – Kill process
  • kill -9 <PID> – Force kill
  • renice <PRIORITY> <PID> – Change priority

πŸ“ Logging (logcat)

  • logcat – View logs
  • logcat -c – Clear logs
  • logcat -d – Dump and exit
  • logcat -v <FORMAT> – Choose format
  • logcat <TAG>:<PRIORITY> *:S – Filter logs (Priorities: V, D, I, W, E, F, S)

🎯 Input & Events

  • input text "<TEXT>" – Simulate typing
  • input keyevent <KEYCODE> – Simulate key press
  • input tap <X> <Y> – Simulate tap
  • input swipe <X1> <Y1> <X2> <Y2> [DUR] – Simulate swipe
  • getevent – Monitor input events
  • sendevent – Send low-level input events

πŸ“Έ Screenshots & Recording

  • screencap /sdcard/screenshot.png – Take screenshot
  • screenrecord /sdcard/video.mp4 – Record screen
  • screenrecord --time-limit 10 <FILE> – Limit duration
  • screenrecord --size <WxH> – Set video size
  • screenrecord --bit-rate <BPS> – Set bitrate

πŸ”§ Device Control

  • reboot, reboot bootloader, reboot recovery – Reboot device
  • setenforce [0|1] – Toggle SELinux mode (root)
  • getenforce – Show SELinux mode

πŸ›  Other Useful Commands

  • date – Show/set date/time
  • id, whoami – Show user info
  • vmstat – Virtual memory stats
  • which <COMMAND> – Find command path
  • monkey -p <PACKAGE> -v <EVENT_COUNT> – UI stress test
  • cmd <SERVICE> ... – Interact with system services