ADB (Android Debug Bridge) Cheatsheet

2548




Selecting Device

CommandDescription
adb devicesThis command is used to retrieve all devices by serial number
adb devices -lList of devices by product/model
adb -s <device> <command>Use the -s option followed by a device name to select on which device the adb command should run. The -s options should be first in line, before the command.

App installation & uninstallation

CommandDescription
adb install <apk>Install app
adb shell pm install <path_from_phone>Install app from phone path
adb shell pm install -r <path_from_phone>Reinstall app from phone path
adb uninstall <com.test.package.name>Remove the app

App info

CommandDescription
adb shell pm list packagesList package names
adb shell pm list packages -fas above + path tp APks
adb shell pm -3only third party packages
adb shell pm -sonly system packages
adb shell pm -ualso uninstalled packages
adb shell dumpsys package packagesList info on all apps
adb shell pm dump nameList info on one package
adb shell pm path packagepath to the APK file

Permissions

CommandDescription
adb shell pm permission groupsPermission groups definitions
adb shell pm list permissions -g -fList permissions details

Common actions

CommandDescription
am start -a android.intent.action.VIEW -d URLTo open the URL

Miscellaneous

CommandDescription
screencap -p .pngScreenshot (saved on device)
screenrecord .mp4Screen capture (path on device)

Copy files to/from a device

CommandDescription
adb pull <remote> <local>To copy a file or directory and its sub-directories from the device
adb push <local> <remote>To copy a file or directory and its sub-directories to the device

Replace local and remote with the paths to the target files/directory on your development machine (local) and on the device (remote).For example:<br />
adb push foo.txt /sdcard/foo.txt

ADB daemon

CommandDescription
adb kill-serverKill the server if it is running
adb start-serverEnsure that there is a server running
adb rootRestarts the adbd with root permissions

Steps to pair and connect to adb over wifi [Android 11+]

  1. On device, go to developer settings and enable wireless debugging
  2. Type adb pair [ip]:[port] and replace [ip] and [port] with the ip and port shown on the device
  3. Then you will be asked for a pairing code.Enter that as shown on the device.
  4. Now to connect type adb connect [ip]:[port] and replace [ip] and [port] with the the ip and port seen on the Wireless debugging page after closing the pairing dialog.