Introduction
ADB (Android Debug Bridge) is a powerful command-line tool for interacting with Android devices. It allows developers, testers, and advanced users to install apps, manage files, obtain system logs, execute shell commands on the device, and perform low-level operations. This cheat sheet compiles the most frequently used ADB and Fastboot commands to simplify debugging, administration, and everyday management of Android devices.
Requirements
Before you begin, ensure the following conditions are met:
- Android SDK Platform-Tools are installed on your computer (they contain
adbandfastboot). Download from the official Google website. - USB debugging is enabled on the Android device: Settings → About phone → Build number (tap 7 times) → Settings → Developer options → USB debugging.
- The device is connected to the computer via a USB cable (original or high-quality alternative recommended).
- For Windows, ADB/Fastboot drivers may be required (usually installed automatically or manually from the
usb_driverfolder). - The PATH environment variable must include the
platform-toolsfolder (or run commands from within that folder).
Basic Device Interaction Commands
These commands form the foundation for any interaction with a device via ADB. They allow you to check connectivity, manage device state, copy files, and install apps.
| Command | Description | Example |
|---|---|---|
adb devices | Show list of connected devices and their status (device, offline, unauthorized) | adb devices |
adb shell | Open an interactive shell on the device. To exit: exit | adb shell |
adb reboot | Reboot the device into normal mode | adb reboot |
adb reboot recovery | Reboot into Recovery mode | adb reboot recovery |
adb reboot bootloader | Reboot into Bootloader (Fastboot) mode | adb reboot bootloader |
adb pull <remote> <local> | Copy a file or folder from the device to the computer | adb pull /sdcard/file.txt ./file.txt |
adb push <local> <remote> | Copy a file or folder from the computer to the device | adb push ./file.txt /sdcard/ |
adb install <apk> | Install an APK file on the device. Flag -r reinstalls, -t allows test APKs | adb install -r app.apk |
adb uninstall <package> | Uninstall an app by its package name (e.g., com.example.app) | adb uninstall com.example.app |
adb shell pm list packages | List all installed packages. Flag -3 shows only third-party apps | adb shell pm list packages -3 |
App Management
These commands allow you to manage the app lifecycle, obtain information about apps, and perform actions without a graphical interface.
| Command | Description | Example |
|---|---|---|
adb shell am start -n <package>/<activity> | Launch a specific app activity | adb shell am start -n com.android.settings/.Settings |
adb shell am force-stop <package> | Force-stop an app | adb shell am force-stop com.example.app |
adb shell pm clear <package> | Clear app data (reset to "as installed" state) | adb shell pm clear com.example.app |
adb shell pm disable-user --user 0 <package> | Disable an app for the current user (without uninstalling) | adb shell pm disable-user --user 0 com.example.app |
adb shell pm enable <package> | Enable a previously disabled app | adb shell pm enable com.example.app |
adb shell dumpsys package <package> | Get detailed package info: permissions, activities, services | adb shell dumpsys package com.example.app |
adb shell monkey -p <package> -v 1000 | Perform 1000 random events in the app (stress test) | adb shell monkey -p com.example.app -v 500 |
File System Operations
Commands for navigating, viewing, and manipulating files and folders on the device.
| Command | Description | Example |
|---|---|---|
adb shell ls /path | List files and folders in the specified directory | adb shell ls /sdcard/ |
adb shell mkdir /path | Create a new directory | adb shell mkdir /sdcard/new_folder |
adb shell rm /path | Delete a file. Use flag -r for folders | adb shell rm /sdcard/file.txt |
adb shell cp <from> <to> | Copy a file or folder | adb shell cp /sdcard/file.txt /sdcard/backup/ |
adb shell mv <from> <to> | Move or rename a file/folder | adb shell mv /sdcard/old.txt /sdcard/new.txt |
adb shell cat /path | Output the contents of a text file to the terminal | adb shell cat /sdcard/log.txt |
adb shell chmod <permissions> <file> | Change access permissions (e.g., 755 for an executable script) | adb shell chmod 755 /sdcard/script.sh |
adb shell df | Show free space information on partitions | adb shell df |
Debugging and Logs
Commands for obtaining system information, monitoring activity, and analyzing logs.
| Command | Description | Example |
|---|---|---|
adb logcat | Show system log in real-time. To exit: Ctrl+C | adb logcat |
adb logcat -s <tag> | Filter log by tag (e.g., ActivityManager, MyApp) | adb logcat -s MyApp |
adb logcat -d > log.txt | Save the current log to a log.txt file on the computer | adb logcat -d > log.txt |
adb shell dumpsys | Dump information about all system services | adb shell dumpsys |
adb shell dumpsys battery | Get battery status | adb shell dumpsys battery |
adb shell getprop | Get a system property value (build parameters, settings) | adb shell getprop ro.build.version.release |
| `adb shell getprop | grep | Find a property by keyword |
adb shell wm size | Get the current screen resolution | adb shell wm size |
adb shell wm density | Get pixel density (dpi) | adb shell wm density |
adb shell settings get <namespace> <key> | Get a setting value (e.g., brightness) | adb shell settings get system screen_brightness |
Fastboot Commands
Fastboot is used when the device is booted into the bootloader. Commands are executed via the fastboot utility (included in Platform-Tools). To enter fastboot: adb reboot bootloader.
| Command | Description | Example |
|---|---|---|
fastboot devices | Show devices in fastboot mode | fastboot devices |
fastboot reboot | Reboot the device into the normal system | fastboot reboot |
fastboot reboot recovery | Reboot into Recovery mode | fastboot reboot recovery |
fastboot flash <partition> <image> | Flash a specific partition with an image | fastboot flash boot boot.img |
fastboot flash recovery recovery.img | Flash a custom recovery | fastboot flash recovery recovery.img |
fastboot erase <partition> | Erase a partition (e.g., userdata, cache) | fastboot erase userdata |
fastboot oem unlock | Unlock the bootloader (all data on the device will be erased!) | fastboot oem unlock |
fastboot oem lock | Lock the bootloader (return to stock state) | fastboot oem lock |
fastboot getvar <variable> | Get a bootloader variable (e.g., product, version) | fastboot getvar product |
fastboot flash:raw boot <boot.img> | Alternative flashing method (for some devices) | fastboot flash:raw boot boot.img |
⚠️ Important: Fastboot commands can render a device unusable (brick). Always read the documentation for your specific model, ensure image compatibility, and have sufficient battery charge (at least 50%).
Verifying Results
After executing any ADB/Fastboot command, the result is displayed in the terminal:
- Success: Many commands produce no output on success (e.g.,
adb install). Verify indirectly (app installed, file appeared). - Device status:
adb devicesshould list your device with statusdevice. Ifunauthorized— confirm the prompt on the device. - Logs: For commands that should produce output (e.g.,
adb shell getprop), check that the output matches expectations. - Permissions: Some commands require superuser (root) privileges. If you get
Permission denied, tryadb root(on user builds) oradb shell su -c <command>(if the device is rooted).
Common Issues
Device not showing up in adb devices
- Cause: USB debugging not enabled or confirmed, faulty cable/port, missing drivers.
- Solution:
- Check if USB debugging is enabled in Developer options.
- Reconnect the cable, try a different port or cable.
- On Windows: install ADB drivers (e.g., via Universal ADB Drivers) or restart the ADB server:
adb kill-server && adb start-server. - On the device, change the USB mode to "File Transfer (MTP)" or "PTP".
"device offline" error
- Cause: ADB server cannot establish a connection with the device.
- Solution:
- Disconnect and reconnect the device, confirm the debugging prompt.
- Restart ADB:
adb kill-server && adb start-server. - Reboot both the device and the computer.
"error: closed" or "no devices/emulators"
- Cause: ADB server is not running or port 5037 (default for ADB) is in use.
- Solution: Run
adb start-serveror terminate processes using port 5037.
Fastboot does not recognize the device
- Cause: Device not in fastboot mode, missing drivers (Windows), cable does not support data transfer.
- Solution:
- Ensure the device screen shows the fastboot logo (usually a black screen with text).
- For Windows: install fastboot drivers (e.g., from the
usb_driverfolder in Platform-Tools or via Zadig). - Try a different USB port (USB 2.0 preferred) and cable.
"Permission denied" when running commands in adb shell
- Cause: Command requires superuser (root) privileges, but the device is not rooted.
- Solution:
- Obtain root access on the device (if supported).
- Use
adb shell su -c "<command>"to execute the command as root. - For some system commands (e.g.,
setprop), a reboot into ADB root mode is required:adb root(works only on user builds like AOSP).
APK installation does not complete
- Cause: Insufficient storage, permission conflict, or corrupted APK.
- Solution:
- Check free space:
adb shell df. - Install with the
-rflag to reinstall:adb install -r app.apk. - Ensure the APK is compatible with the device's architecture and Android version.
- Use
adb logcatduring installation for debugging.
- Check free space: