Back to Cheatsheets

adb (Android Debug Bridge)

CLI2018-03-06

Device Basics

CommandDescription
adb devicesLists connected devices
adb devices -lLists connected devices and kind
------
adb rootRestarts adbd with root permissions
adb start-serverStarts the adb server
adb kill-serverKills the adb server
adb remountRemounts file system with read/write access
adb rebootReboots the device
adb reboot bootloaderReboots the device into fastboot
adb disable-verityReboots the device into fastboot

wait-for-device can be specified after adb to ensure that the command will run once the device is connected.

-s can be used to send the commands to a specific device when multiple are connected.

Examples

$ adb wait-for-device devices
 List of devices attached
 somedevice-1234 device
 someotherdevice-1234 device
$ adb -s somedevice-1234 root

Logcat

CommandDescription
adb logcatStarts printing log messages to stdout
adb logcat -gDisplays current log buffer sizes
adb logcat -G <size>Sets the buffer size (K or M)
adb logcat -cClears the log buffers
adb logcat *:VEnables ALL log messages (verbose)
adb logcat -f <filename>Dumps to specified file

Examples

$ adb logcat -G 16M
$ adb logcat *:V > output.log

File Management

CommandDescription
adb push <local> <remote>Copies the local to the device at remote
adb pull <remote> <local>Copies the remote from the device to local

Examples

$ echo "This is a test" > test.txt
$ adb push  test.txt /sdcard/test.txt
$ adb pull /sdcard/test.txt pulledTest.txt

Remote Shell

CommandDescription
adb shell <command>Runs the specified command on device (most unix commands work here)
adb shell wm sizeDisplays the current screen resolution
adb shell wm size WxHSets the resolution to WxH
adb shell pm list packagesLists all installed packages
adb shell pm list packages -3Lists all installed 3rd-party packages
adb shell monkey -p app.package.nameStarts the specified package