If you’re an Android enthusiast like me, you’ve probably heard about the Android Debug Bridge (ADB) – a versatile command-line tool that lets you communicate with a device. Whether you’re a developer looking to debug an app, or a power user wanting to tinker with their device, ADB is an essential tool. You can download it as part of the Android SDK Platform Tools package.
You can use ADB to perform various tasks, such as installing apps, debugging, accessing hidden features, and more. In this article, we will show you a detailed list of all ADB commands for Android, along with a brief description and an example for each one.
adb provides access to a Unix shell on your Windows PC or Mac that you can use to run a variety of commands on an Android device. It is a client-server program that includes three components:
- Client, which sends commands. The client runs on your development machine. You can invoke a client from a command-line terminal by issuing an
- Daemon (adbd), which runs commands on a device. The daemon runs as a background process on each device.
- Server, which manages communication between the client and the daemon. The server runs as a background process on your development machine.
All ADB Commands List Directory
There are only a handful of commands listed in the official adb documentation, but with additional arguments and parameters, that number could go very high. You can save this ADB cheat sheet guide for whenever you want to perform any debugging action on your device.
Before you can use ADB commands, you need to install Android USB drivers, enable USB debugging on your Android device and install the ADB tools on your computer. Once you have set up everything, you can open a terminal or command prompt window and type adb followed by the command you want to execute.
adb devices command provides a list of devices that are currently connected to your computer.
Running this command will give you an output similar to this:
List of devices attached emulator-5554 device
adb push, you can transfer a file or directory from your computer to your Android device.
Suppose you have a file named “sample.txt” on your computer and you want to transfer it to your device’s
adb push sample.txt /sdcard/
The opposite of
adb push, the
adb pull command lets you copy a file or directory from your Android device to your computer.
Let’s say you want to fetch a file named “sample.txt” from the
/sdcard/ directory of your device.
adb pull /sdcard/sample.txt .
For those who sideload apps frequently, the
adb install command is a godsend. This command allows you to install APKs from your computer onto your Android device. To make this work, you need to copy the APK file into the platforms-tools folder on your computer.
To install an APK named “app.apk”:
adb install app.apk
There are some variations of this command that you should know about.
In case you want to update or reinstall an app without losing its data, you should use the following command:
adb install -r app.apk
And for those who want to install APK files directly to the SD card, you can use the following two commands so the app is not installed in your internal storage:
adb install -s app.apk
adb install -k <APK file path on PC>
If you want to remove an app from your Android phone or tablet using ADB, the
adb uninstall command is what you’ll use. It requires the package name of the app.
To uninstall an app with the package name
adb uninstall com.example.myapp
If you need to restart your device and it’s not at hand, you can easily do so with the
adb reboot command.
Your device will promptly restart.
For developers or those troubleshooting their device, the
adb logcat command displays the device log in real-time. This log provides insights into what’s happening behind the scenes.
To view your device’s logs:
This command also comes with some important parameters and variations that may be useful when debugging.
You should use the following command when you want to clear any existing logs on your device.
adb logcat -c // clear //
And if you want to save the log contents / logcat data to your PC, you should use the following command:
adb logcat -d > <path_to_file> //
adb backup command allows you to create a backup of your device. It’s handy for saving important data before a factory reset.
To create a backup named “backup.ab”:
adb backup -f backup.ab -all
adb backup -apk
adb backup -apk command is used to create a backup of your device’s installed apps along with their APK files. This is particularly useful for app archival.
To create a backup of apps with their APKs:
adb backup -apk -f backup.ab
This command is an extensive version of the
adb backup command, allowing you to create a complete backup of your device, including apps, app data, and system data.
To create a comprehensive backup:
adb backup -all -apk -obb -shared -system -f backup.ab
After backing up your data, you can restore it using the
adb restore command.
To restore from a backup named “backup.ab”:
adb restore backup.ab
adb sideload command is useful for flashing zip files, especially OTA updates, onto your device without transferring them first.
To sideload an OTA update named “update.zip”:
adb sideload update.zip
If you’re working with system files, you may need to remount the
/system partition in read-write mode. The
adb remount command lets you do just that.
To remount the system partition:
adb shell command, you can start a remote command-line session on your Android device from your computer.
And you’ll get a command prompt where you can run commands directly on your device.
adb shell screencap
Want to take a screenshot directly from the command line? The
adb shell screencap command lets you capture the device’s current screen.
To save a screenshot as “screenshot.png” on your device’s storage:
adb shell screencap /sdcard/screenshot.png
adb shell screenrecord
adb shell screenrecord command is a gem for recording the screen of your device. This is especially helpful for developers or content creators.
To start recording the screen and save it as “recording.mp4”:
adb shell screenrecord /sdcard/recording.mp4
adb shell dumpsys
adb shell dumpsys command is a powerful one. It provides comprehensive information about system services. Developers often use this to extract in-depth details for troubleshooting.
To get information about the battery:
adb shell dumpsys battery
adb shell setprop
If you want to change system properties,
adb shell setprop is the command you need. Remember, tweaking these properties can affect system behavior, so proceed with caution.
To change the device’s density:
adb shell setprop ro.sf.lcd_density 240
adb shell wm
adb shell wm command allows you to interact with the window manager, which controls elements like screen density and screen size.
To set the device’s screen density to 240:
adb shell wm density 240
adb shell wm size
adb shell wm size command lets you change the screen size or resolution of your Android device, which can be helpful for testing app compatibility.
To set the screen size to 1080×1920:
adb shell wm size 1080x1920
adb shell pm
adb shell pm command is used for package management tasks like listing installed packages or uninstalling apps.
To list all installed packages:
adb shell pm list packages
adb shell input
adb shell input command allows you to simulate user input events like taps, swipes, or key presses.
To simulate a tap at coordinates (500, 700):
adb shell input tap 500 700
adb shell am
adb shell am command is a versatile tool for interacting with Android’s Activity Manager, enabling actions like starting activities and broadcasting intents.
To start an activity:
adb shell am start -n com.example.myapp/.MainActivity
adb shell dumpstate
adb shell dumpstate command generates a bug report of the device’s current state, which can be useful for diagnosing issues.
To create a bug report:
adb shell dumpstate > bugreport.txt
adb shell pm list users
adb shell pm list users command displays a list of user accounts on the Android device. This can be useful for managing user profiles on a multi-user device.
To list the user accounts on the device:
adb shell pm list users
adb shell wm overscan
adb shell wm overscan command lets you adjust overscan settings, which can be helpful for adjusting the display on certain devices or screens.
To reduce overscan by 5% in all directions:
adb shell wm overscan 5,5,5,5
adb shell wm density
adb shell wm density command allows you to change the screen density of your device temporarily, which can be useful for testing app layouts on different screen densities.
To set the screen density to 320:
adb shell wm density 320
adb shell input text
adb shell input text command allows you to simulate text input on your Android device. This can be useful for automated testing or filling out forms.
To input the text “Hello, Android!”:
adb shell input text "Hello, Android!"
adb shell input swipe
adb shell input swipe command, you can simulate a swipe or gesture on the touchscreen of your Android device.
To simulate a swipe from (100, 500) to (300, 500):
adb shell input swipe 100 500 300 500
adb shell input keyevent
adb shell input keyevent command allows you to simulate key presses on the device, such as volume control or media playback.
To simulate the volume up key press:
adb shell input keyevent 24
adb shell dumpsys batteryinfo
adb shell dumpsys batteryinfo command provides detailed information about the battery status and usage, which can be useful for diagnosing battery-related issues.
To get battery information:
adb shell dumpsys batteryinfo
adb shell cat
adb shell cat command allows you to view the contents of files on the Android device directly in the terminal.
To view the contents of a text file named “example.txt”:
adb shell cat /path/to/example.txt
adb shell pm hide
adb shell pm hide command lets you hide a specific package on your Android device. This can be useful for disabling pre-installed apps.
To hide a package with the name “com.example.app”:
adb shell pm hide com.example.app
To fetch the serial number of the connected device, use the
adb get-serialno command.
This command shows the ADB status of the connected Android phone, tablet, watch or an emulator.
If you’re running a script and want to ensure that the ADB command only runs when your device is connected, the
adb wait-for-device command pauses the script execution until a device is detected.
adb wait-for-device shell
adb wait-for-device was mentioned earlier, combining it with
adb shell can be valuable when you want to execute shell commands only when the device is ready.
To wait for the device and then run a shell command:
adb wait-for-device shell "echo Hello, Android!"
adb forward command sets up port forwarding between your computer and Android device, useful for debugging purposes.
To forward requests from port 5000 on your computer to port 6000 on your device:
adb forward tcp:5000 tcp:6000
If you have multiple APK files to install at once, the
adb install-multiple command allows you to do this efficiently.
To install multiple APKs:
adb install-multiple app1.apk app2.apk app3.apk
adb tcpip command allows you to switch from USB to TCP/IP mode for ADB connections, which can be useful when you want to connect wirelessly.
To switch to TCP/IP mode on port 5555:
adb tcpip 5555
You can use the
adb start-server command if it stops working on your phone or the PC. This is used to start the ADB server on your Android device.
If your ADB commands stop working or become unresponsive, you can easily kill the ADB server on your Android device with the
adb kill-server command.
adb connect ip_address_of_device
adb connect ip_address_of_device command is used to find the IP address of the connected Android device and connect it to the PC.
You can use the adb jdwp command to see the list of all the JDWP processes on your PC. JDWP is short for Java Debug Wire Protocol.
I hope this list gives you a solid introduction to some of the most common ADB commands out there. Remember, while ADB is a powerful tool, always ensure you know the consequences of the commands you’re running – especially if you’re new to ADB. I’d advise you to bookmark this page as I will be updating it with newer commands (as I learn them) over time.
If there are any more commands that you think should be included in the list above, drops us a comment below and lets us know. You can also visit the ADB documentation page for more information about this tool.