Android ADB Commands Cheat Sheet: The Ultimate Developer’s Guide

Introduction

Android Debug Bridge (ADB) is a versatile command-line tool that lets you communicate with Android devices. It’s an essential utility for developers, testers, and power users that facilitates a wide variety of device actions—from basic tasks like installing and debugging apps to advanced operations like running shell commands on the device. This cheatsheet provides a comprehensive collection of ADB commands organized by their function to help you navigate Android device management efficiently.

Core ADB Concepts

Components of ADB

  • ADB Client: The command-line tool on your computer
  • ADB Server: Background service running on your computer
  • ADB Daemon (adbd): Background process running on Android devices

Connection Modes

  • USB Debugging: Physical connection via USB cable
  • Wireless Debugging: Connection over Wi-Fi network
  • TCP/IP Debugging: Remote connection using IP address

Getting Started with ADB

Installation and Setup

  1. Download and install Android SDK Platform Tools
  2. Add ADB to your system PATH
  3. Enable Developer Options on your Android device
  4. Enable USB Debugging in Developer Options
  5. Connect your device via USB and authorize the connection

Basic Connection Commands

CommandDescription
adb devicesList all connected devices
adb devices -lList devices with additional details
adb kill-serverTerminate the ADB server process
adb start-serverStart the ADB server process
adb connect <IP>:<PORT>Connect to a device over Wi-Fi
adb disconnect <IP>:<PORT>Disconnect from a Wi-Fi device
adb usbRestart ADB in USB mode
adb tcpip <PORT>Restart ADB in TCP/IP mode
adb -s <DEVICE_ID> <COMMAND>Execute command on specific device
adb wait-for-deviceBlock until a device is connected

App Management Commands

Installation and Uninstallation

CommandDescription
adb install <APK_FILE>Install an APK
adb install -r <APK_FILE>Install an APK, replacing existing app
adb install -s <APK_FILE>Install APK to SD card
adb install-multiple <APK_FILES>Install multiple APKs
adb uninstall <PACKAGE_NAME>Uninstall an app
adb uninstall -k <PACKAGE_NAME>Uninstall app but keep data/cache

App Data and Management

CommandDescription
adb shell pm list packagesList all installed packages
adb shell pm list packages -sList system packages
adb shell pm list packages -3List third-party packages
adb shell pm clear <PACKAGE_NAME>Clear app data and cache
adb shell pm disable <PACKAGE_NAME>Disable an app
adb shell pm enable <PACKAGE_NAME>Enable an app
adb shell pm path <PACKAGE_NAME>Get APK path of an app
adb shell dumpsys package <PACKAGE_NAME>Get detailed info about an app

Device Control and System Management

Power Management

CommandDescription
adb rebootReboot the device
adb reboot bootloaderReboot into bootloader/fastboot
adb reboot recoveryReboot into recovery mode
adb reboot sideloadReboot into sideload mode
adb shell reboot -pPower off the device
adb shell input keyevent 26Turn screen on/off

System Information

CommandDescription
adb shell getpropGet all system properties
adb shell getprop <PROPERTY>Get specific system property
adb shell setprop <PROPERTY> <VALUE>Set system property
adb shell settings list systemList all system settings
adb shell settings get system <SETTING>Get system setting value
adb shell settings put system <SETTING> <VALUE>Set system setting value
adb shell dumpsysDump all system service info
adb shell dumpsys batteryGet battery information
adb shell dumpsys cpuinfoGet CPU information
adb shell dumpsys meminfoGet memory usage information
adb shell dumpsys activityGet activity information
adb shell dumpsys windowGet window information

Device Features and Specifications

CommandDescription
adb shell pm list featuresList device features
adb shell wm sizeGet screen resolution
adb shell wm densityGet screen density
adb shell cat /proc/cpuinfoGet CPU details
adb shell cat /proc/meminfoGet memory details
adb shell dfGet disk space information

File Management Commands

File Transfer

CommandDescription
adb push <LOCAL> <REMOTE>Copy file/dir to device
adb pull <REMOTE> <LOCAL>Copy file/dir from device
adb shell ls <PATH>List directory contents
adb shell rm <FILE>Delete a file
adb shell mkdir <DIRECTORY>Create a directory
adb shell touch <FILE>Create an empty file
adb shell cp <SOURCE> <DESTINATION>Copy files
adb shell mv <SOURCE> <DESTINATION>Move files
adb shell cat <FILE>Display file contents

Storage Management

CommandDescription
adb shell dfShow disk usage
adb shell du <PATH>Show directory size
adb shell mountShow mounted filesystems
adb shell ls -la /storage/List storage volumes
adb shell find <PATH> -name "<PATTERN>"Find files by name

Debugging and Logging Commands

Logcat Commands

CommandDescription
adb logcatView device logs
adb logcat -v timeView logs with timestamps
adb logcat -b allView all log buffers
adb logcat *:EView only error logs
adb logcat -cClear log buffer
adb logcat > logfile.txtSave logs to file
adb logcat -dDump logs and exit
adb logcat <TAG>:<LEVEL>Filter logs by tag and level
adb logcat | grep "<TEXT>"Filter logs by text

Debugging Commands

CommandDescription
adb jdwpList JDWP processes
adb forward tcp:<LOCAL> jdwp:<PID>Forward port for JDWP debugging
adb shell am start -D -n <PACKAGE>/<ACTIVITY>Start app in debug mode
adb shell psList running processes
adb shell topShow process resource usage
adb shell monkey -p <PACKAGE> <COUNT>Stress test an app
adb bugreport > bugreport.zipGenerate bug report

Network and Connectivity Commands

Network Information

CommandDescription
adb shell netstatDisplay network statistics
adb shell ip addr showShow IP addresses
adb shell ifconfigNetwork interface configuration
adb shell ping <HOST>Ping a host
adb shell netcfgShow network configuration
adb shell dumpsys connectivityShow connectivity info
adb shell dumpsys wifiShow Wi-Fi information
adb shell dumpsys bluetooth_managerShow Bluetooth info

Port Forwarding

CommandDescription
adb forward tcp:<LOCAL> tcp:<REMOTE>Forward local port to device port
adb forward --listList all port forwards
adb forward --remove tcp:<LOCAL>Remove specific port forward
adb forward --remove-allRemove all port forwards
adb ppp <TUN> <PARAMETERS>Run PPP over USB

UI Automation Commands

Input Commands

CommandDescription
adb shell input text "<TEXT>"Type text
adb shell input keyevent <KEYCODE>Send keycode
adb shell input tap <X> <Y>Tap at coordinates
adb shell input swipe <X1> <Y1> <X2> <Y2>Swipe from one point to another
adb shell input swipe <X1> <Y1> <X2> <Y2> <DURATION>Swipe with duration
adb shell input draganddrop <X1> <Y1> <X2> <Y2>Drag and drop
adb shell wm overscan <LEFT>,<TOP>,<RIGHT>,<BOTTOM>Set overscan area

Screenshots and Screen Recording

CommandDescription
adb shell screencap -p /sdcard/screen.pngTake screenshot
adb pull /sdcard/screen.pngPull screenshot to computer
adb shell screenrecord /sdcard/video.mp4Record screen (max 3 minutes)
adb shell screenrecord --time-limit <SECONDS> <FILE>Record screen with time limit
adb shell screenrecord --bit-rate <RATE> <FILE>Record with custom bitrate
adb shell screenrecord --size <WIDTHxHEIGHT> <FILE>Record with custom resolution

Activity and Service Management

Activity Management

CommandDescription
adb shell am start -n <PACKAGE>/<ACTIVITY>Start an activity
adb shell am startservice <SERVICE>Start a service
adb shell am broadcast -a <ACTION>Send broadcast
adb shell am force-stop <PACKAGE>Force stop an app
adb shell am kill <PACKAGE>Kill app processes
adb shell am kill-allKill all background processes
adb shell am stack listList activity stacks
adb shell dumpsys activity activitiesShow activity stack info

Intent Commands

CommandDescription
adb shell am start -a <ACTION> -d <DATA>Start activity with action and data
adb shell am start -a android.intent.action.VIEW -d <URL>Open URL
adb shell am start -a android.intent.action.CALL -d tel:<NUMBER>Make a phone call
adb shell am start -n <PACKAGE>/<ACTIVITY> --es <EXTRA_KEY> <EXTRA_STRING_VALUE>Start with string extra
adb shell am start -n <PACKAGE>/<ACTIVITY> --ei <EXTRA_KEY> <EXTRA_INT_VALUE>Start with integer extra
adb shell am start -n <PACKAGE>/<ACTIVITY> --ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE>Start with boolean extra

Security and Permissions

Permission Management

CommandDescription
adb shell pm list permissions -gList permission groups
adb shell pm list permissions -d -gList dangerous permissions
adb shell pm grant <PACKAGE> <PERMISSION>Grant a permission
adb shell pm revoke <PACKAGE> <PERMISSION>Revoke a permission
adb shell dumpsys package <PACKAGE> | grep permissionList app permissions

Security Commands

CommandDescription
adb disable-verityDisable dm-verity checking
adb enable-verityEnable dm-verity checking
adb rootRestart ADB with root permissions
adb unrootRestart ADB without root permissions
adb shell suSwitch to superuser (if available)
adb shell getenforceGet SELinux mode
adb shell setenforce 0Set SELinux to permissive mode
adb shell setenforce 1Set SELinux to enforcing mode

Advanced ADB Shell Commands

Shell Environment

CommandDescription
adb shellStart interactive shell
adb shell <COMMAND>Run shell command
adb shell echo $PATHShow shell path
adb shell export <VAR>=<VALUE>Set environment variable
adb shell sh -c "<COMMANDS>"Run multiple commands
adb exec-out <COMMAND>Run command and get raw output

Package Management (PM)

CommandDescription
adb shell pm trim-caches <SIZE>Trim cache to size in MB
adb shell pm create-user <NAME>Create a new user
adb shell pm remove-user <USER_ID>Remove a user
adb shell pm get-max-usersGet maximum user count
adb shell pm list usersList all users
adb shell pm list featuresList device features
adb shell pm set-install-location <LOCATION>Set default install location

Wireless Debugging (Android 11+)

CommandDescription
adb pair <IP>:<PORT> <PAIRING_CODE>Pair with a device
adb connect <IP>:<PORT>Connect to paired device
adb pair-devicesList paired devices

Common Challenges and Solutions

ADB Connection Issues

ProblemSolution
“adb devices” shows no devices1. Check USB cable<br>2. Restart ADB server with adb kill-server followed by adb start-server<br>3. Reinstall USB drivers<br>4. Try different USB port
“unauthorized” device1. Unlock phone<br>2. Confirm USB debugging prompt<br>3. Revoke USB debugging authorizations and try again
Multiple devices errorUse -s <DEVICE_ID> to specify target device
Wi-Fi connection drops1. Ensure device and computer are on same network<br>2. Use static IP on Android device<br>3. Reconnect using adb connect <IP>:<PORT>

Common Error Messages

ErrorSolution
“device offline”1. Reconnect USB cable<br>2. Restart device<br>3. Restart ADB server
“device not found”1. Check USB connection<br>2. Verify device is in proper mode (not in recovery/bootloader)
“insufficient permissions”1. Run ADB as administrator/root<br>2. Check USB device permissions
“failed to install *.apk”1. Check if app is already installed<br>2. Verify APK is not corrupted<br>3. Ensure sufficient storage space
“command not found”1. Update Android SDK Platform Tools<br>2. Check ADB path in environment variables

Best Practices and Tips

Performance Optimization

  • Use adb shell dumpsys gfxinfo <PACKAGE> to analyze UI rendering performance
  • Monitor battery usage with adb shell dumpsys batterystats
  • Check memory usage with adb shell dumpsys meminfo <PACKAGE>
  • Analyze network usage with adb shell dumpsys netstats

Security Best Practices

  • Disable USB debugging when not in use
  • Use adb disconnect after wireless debugging sessions
  • Periodically revoke USB debugging authorizations
  • Always validate the fingerprint when connecting to a new computer

Workflow Efficiency

  • Create shell scripts or aliases for frequently used command sequences
  • Use adb -s <DEVICE_ID> in scripts to target specific devices
  • Combine commands with shell pipes for advanced filtering
  • Use adb shell am start-activity -W to measure app startup time

Time-Saving Tips

  • Use adb shell wm density reset to reset display density without rebooting
  • Clear logcat buffer before debugging with adb logcat -c
  • Use adb bugreport to collect comprehensive system information
  • Install multiple APKs at once with adb install-multiple

Resources for Further Learning

Official Documentation

Useful Tools

  • scrcpy – Display and control Android devices from desktop
  • ADB-Enhanced – ADB wrapper with additional functionality
  • ADB Shell – Terminal emulator for Android

Community Resources

Reference Tables

Common Keycodes for Input Events

KeycodeDescriptionCommand
3HOMEadb shell input keyevent 3
4BACKadb shell input keyevent 4
5CALLadb shell input keyevent 5
6END CALLadb shell input keyevent 6
24VOLUME UPadb shell input keyevent 24
25VOLUME DOWNadb shell input keyevent 25
26POWERadb shell input keyevent 26
27CAMERAadb shell input keyevent 27
61TABadb shell input keyevent 61
66ENTERadb shell input keyevent 66
67DELETEadb shell input keyevent 67
82MENUadb shell input keyevent 82
187APP SWITCHadb shell input keyevent 187
Scroll to Top