adb cheat sheet
Summary
This Android Debug Bridge (adb) cheat sheet helps you control, debug, and manage Android devices via command line. It covers device connections, app management, file operations, logging, and automation in categorized tables.
Introduction #
Android Debug Bridge (adb) is a versatile command-line tool that allows you to communicate with Android devices. It is part of the Android Software Development Kit (SDK) and is primarily used for app debugging, file transfer, device management, and accessing system features via shell.
Command reference #
This cheat sheet provides commands for device control, debugging, app management, file operations, and automation.
Device connection & control #
Commands for detecting, connecting, and managing devices.
| Command | Description |
|---|---|
adb devices | Lists all connected devices (USB/Wi-Fi). |
adb -s <serial> <command> | Targets a specific device (if multiple connected). |
adb tcpip 5555 | Enables TCP/IP debugging (Wi-Fi mode). |
adb connect <IP>:5555 | Connects to a device over Wi-Fi. |
adb disconnect | Disconnects all network devices. |
adb kill-server | Force-stops the ADB server. |
adb start-server | Restarts the ADB server. |
adb reboot | Reboots the device normally. |
adb reboot recovery | Reboots into recovery mode. |
adb reboot bootloader | Reboots into fastboot/bootloader mode. |
adb root | Restarts ADB with root permissions (if supported). |
adb remount | Remounts /system as writable (requires root). |
App management #
Commands for installing, uninstalling, and debugging apps.
| Command | Description |
|---|---|
adb install app.apk | Installs an APK file. |
adb install -r app.apk | Reinstalls while keeping data. |
adb install -t | Allows test packages. |
adb install -d | Allows downgrading an app. |
adb uninstall com.example.pkg | Uninstalls an app. |
adb uninstall -k com.example.pkg | Uninstalls but keeps data. |
adb shell pm list packages | Lists all installed apps. |
adb shell pm list packages -3 | Lists only third-party apps. |
adb shell pm path com.example.pkg | Shows APK path of an app. |
adb shell cmd package install-existing com.example.pkg | Reinstalls a preinstalled app. |
adb shell am start -n com.example.pkg/.MainActivity | Launches an app. |
adb shell am force-stop com.example.pkg | Force-stops an app. |
File operations #
Commands for transferring and managing files.
| Command | Description |
|---|---|
adb push local.txt /sdcard/remote.txt | Copies a file to the device. |
adb pull /sdcard/remote.txt local.txt | Copies a file from the device. |
adb sync | Syncs files between PC and device. |
adb shell ls /sdcard | Lists files in a directory. |
adb shell rm /sdcard/file.txt | Deletes a file. |
adb shell mkdir /sdcard/new_folder | Creates a directory. |
adb shell screencap /sdcard/screen.png | Takes a screenshot. |
adb shell screenrecord /sdcard/video.mp4 | Records screen (stop with Ctrl+C). |
Debugging & logs #
Commands for log inspection and system diagnostics.
| Command | Description |
|---|---|
adb logcat | Shows real-time system logs. |
adb logcat -c | Clears the log buffer. |
adb logcat -d > log.txt | Dumps logs to a file. |
adb logcat ActivityManager:I *:S | Filters logs by tag/priority. |
adb logcat --pid=$(adb shell pidof -s com.example.pkg) | Logs only a specific app. |
adb bugreport bugreport.zip | Generates a detailed bug report. |
adb shell dumpsys battery | Shows battery status. |
adb shell dumpsys wifi | Shows Wi-Fi info. |
adb shell dumpsys meminfo com.example.pkg | Shows app memory usage. |
adb shell top -n 1 | Lists CPU usage of processes. |
adb shell ps | Lists running processes. |
adb shell netstat | Shows network connections. |
Automation & input simulation #
Commands for UI testing and automation.
| Command | Description |
|---|---|
adb shell input keyevent KEYCODE_HOME | Simulates a Home button press. |
adb shell input tap 500 500 | Taps at (x, y) coordinates. |
adb shell input swipe 100 500 900 500 200 | Swipes (x1,y1 to x2,y2 in 200ms). |
adb shell input text "Hello" | Types text into a field. |
adb shell uiautomator dump /sdcard/ui.xml | Dumps UI hierarchy for automation. |
adb shell settings put global airplane_mode_on 1 | Toggles airplane mode (1=on, 0=off). |
adb shell settings put system screen_brightness 50 | Sets screen brightness (0-255). |
Backup & restore #
Commands for device backups (may not work on newer Android versions).
| Command | Description |
|---|---|
adb backup -apk -shared -all -f backup.ab | Creates a full backup. |
adb restore backup.ab | Restores from a backup. |
Fastboot basics #
Useful when the device is in bootloader mode (adb reboot bootloader).
| Command | Description |
|---|---|
fastboot devices | Lists connected fastboot devices. |
fastboot reboot | Exits fastboot and reboots. |
fastboot flash recovery recovery.img | Flashes a custom recovery. |
fastboot oem unlock | Unlocks the bootloader (wipes data). |
FAQ's #
Most common questions and brief, easy-to-understand answers on the topic:
What is Android Debug Bridge (adb)?
Android Debug Bridge (adb) is a command-line tool that allows you to communicate with Android devices for development and debugging tasks.
How do I check if adb is installed?
You can run adb version in your terminal. If adb is installed, it will display the version information.
How do I connect a device over Wi-Fi using adb?
Enable TCP/IP on the device using adb tcpip 5555, find the IP address, then run adb connect DEVICE_IP:5555.
How do I install an APK using adb?
Use adb install path/to/app.apk to install an Android Package Kit (APK) file on the connected device.
Can I use adb without USB debugging enabled?
No, USB debugging must be enabled on the Android device to allow adb to communicate with it.
Further readings #
Sources and recommended, further resources on the topic:
- Android: Android Debug Bridge (
adb) - Android Debug Bridge (
adb) repository - Wikipedia: Android Debug Bridge
License
adb cheat sheet by Jonas Jared Jacek is licensed under CC BY-SA 4.0.
This license requires that reusers give credit to the creator. It allows reusers to distribute, remix, adapt, and build upon the material in any medium or format, for noncommercial purposes only. To give credit, provide a link back to the original source, the author, and the license e.g. like this:
<p xmlns:cc="http://creativecommons.org/ns#" xmlns:dct="http://purl.org/dc/terms/"><a property="dct:title" rel="cc:attributionURL" href="https://www.ditig.com/adb-cheat-sheet">adb cheat sheet</a> by <a rel="cc:attributionURL dct:creator" property="cc:attributionName" href="https://www.j15k.com/">Jonas Jared Jacek</a> is licensed under <a href="https://creativecommons.org/licenses/by-sa/4.0/" target="_blank" rel="license noopener noreferrer">CC BY-SA 4.0</a>.</p>For more information see the Ditig legal page.