ADB (Android Debugging Bridge) is a very useful program made by Google to help Android Developers and users. It’s based on command-line interface and can communicate with an Android device to respond to certain commands. Knowledge about these commands can come in handy in many scenarios. Be it a scenario where you are trying to bring your phone back to life from a bricked state or when trying to unlock your device bootloader. Knowing the commands and their usage could save a lot of time.
You might want to test the commands while you go through them, that might require you to have ADB installed on your Computer system. It’s quite easy to set up ADB on your PC, You can follow our guide to ADB installation. The linked guide covers all major platforms. So it’s just a cake walk where you choose your OS and follow the instructions to get ADB running on your machine.
- Before beginning? Setup Your Device To Use ADB
- Basic ADB Commands
- Advanced ADB Commands
- ADB Get-state command
- ADB Get-devpath command
- ADB Remount command
- ADB Forward command
- ADB Reverse command
- ADB Sync command
- ADB Backup command
- ADB Restore command
- ADB Bugreport command
- ADB Disable-verity & ADB Enable-verity commands
- ADB Keygen command
- ADB Root and ADB Unroot commands
- ADB Start-server and Kill-server commands
Before beginning? Setup Your Device To Use ADB
Once you are done setting up ADB in PC, the next step is to configure your Android device. You need to enable USB debugging on your device for this to work. To do so follow the below steps
- Enable Developer mode first.
- Go to Settings > About Phone > Build number.
- Tap on build number until you get the message “You’re now a developer!”
- Enable USB Debugging Options.
- Go to Settings > Additional Settings > Developer option.
- Enable the USB Debugging option.
You can now connect your phone to PC with a USB cable to use the ADB commands, However, when you connect your device, a pop up might appear which might ask you for permissions. Allow it and you can start playing with the commands.
Type adb in command prompt and you will see a lot of commands on your screen. It is cumbersome to understand and analyze all these commands. That’s why we’ve divided the commands into two categories – Basic and Advanced. The basic commands are for normal end users who are either need access to ADB to unlock the bootloader or root their device. The Advanced commands are for developers who already have an idea about the working and want to test the commands for debugging or troubleshooting their app or ROM etc.
Basic ADB Commands
Below are the most commonly used commands to perform basic ADB operations. Let’s take a look at them.
ADB Devices command
The adb devices command would show the list of devices that are attached to your computer with their serial number. This command is generally used by people to check if the ADB on PC is being able to communicate with the device. If you get a response with your device and serial number, it means that your device is properly connected and you could execute other adb commands as well.
ADB Help command
If you’ve used Linux or Unix based operating systems, you might know that every command has a “-h” which helps you with syntax and usage description. This command is similar, it will print a list of supported ADB commands with their descriptions.
ADB Version command
Newer versions of ADB might support the old commands, but the older versions of ADB might not support all the new commands. So if you try a command of a newer version on the older version of ADB, there are chances that it might not work. That’s why we have this command, it helps you to know the version of ADB installed on your system.
ADB Push command
Adb push is one of the file transfer commands. This will move a file onto your Android device programmatically. The parameters for this command includes the Source path and the Destination path.
adb push %SOURCE PATH% %DESTINATION PATH%
- The source path is the path to the file on your PC.
- The destination path is the path on your Android phone where you want to transfer the file in source path.
Example: The below command will push Abc.apk file to the apps folder on the device.
adb push F:\MyApps\Launcher.apk /sdcard/apps/
ADB Pull command
The pull command is the reverse of the push command. The push command sends files from your PC to your Android device, while the pull command sends files from your Android device to your PC.
adb pull %SOURCE PATH% %DESTINATION PATH%
- The source path is the path of the file or folder on your Android Phone which you want to send.
- The destination path is the path of the folder where you want to store the file from the source path.
Example: The below command will send build.prop file to the destination path.
adb pull /system/build.prop F:\Path\To\Destination\Folder\
ADB Shell command
Android OS is based on the Linux kernel, so it can execute Linux commands. There are times when you might want to execute some Linux commands on your Android device. Although, there are apps like Terminal Emulator which helps you to execute them, but it’s a painful experience. Back in time recording the on-screen video required root access. So, people who didn’t want to root their device used the Linux command screenrecord with adb shell command and got it recorded (Check example for the command to record screen using Adb shell.)
adb shell <linux command>
Example 1: The below command would begin recording of the Android screen.
adb shell screenrecord /sdcard/record-video-adb.mp4
Example 2: The below command would list all the files in the directory.
adb shell ls
ADB Install command
The adb install command helps you to install APKs on your phone from your PC. This command is generally used by people who are into app development. Because the developer might want to check multiple versions of his APK during the development phase. Transferring the APK to the device and installing it every time could be a painful thing. So if you are a developer and never knew about this command, don’t worry, this is going to fasten your development process.
adb install %PATH OR FILENAME%
Example 1: The below command would help you install the app from D:\APK\ path.
adb install D:\APK\AppName.apk
Example 2: The below command would work if you’ve either stored the APK in the same folder of ADB binaries or if you’re opening the command prompt inside the folder itself. So if you want to launch ADB from the folder “APK” you shall navigate to the folder, press Shift button + Right click together > Click on “Open command window here.”
adb install TheAppFileName.apk
ADB Reboot command
The reboot command is generally used after unlocking the bootloader or flashing a recovery etc. However, this command is also helpful when the power button on your device isn’t working. You can simply type this command and you’ll be able to reboot your device without even touching the power button. Isn’t it cool?
ADB Reboot Bootloader command
Manufacturers lock the bootloader, to unlock it, we generally need to boot the device into the bootloader mode. You can boot your device into “Bootloader mode” or “Fastboot mode” in two ways. One way is by pressing the key combinations as assigned by the device manufacturer (It’s tough for first timers.) The other includes using this command. You can simply type the reboot bootloader command and ADB would do the work for you. The reboot bootloader command is an extension to the reboot command which we discussed earlier.
adb reboot bootloader
Both the above-mentioned syntax work, Don’t confuse yourself. Different people use different syntax, both are correct and should work. However, if some version of ADB doesn’t support one of them, try the other syntax.
ADB Reboot recovery
The reboot recovery command helps you to boot your device into recovery mode. There are different ways to boot your device into recovery mode, one of them is “Pressing multiple key combinations.” The problem with key combinations is, some users find it difficult and some users have devices where the physical buttons aren’t working. So the simple solution is using this command to reboot their device into recovery mode.
adb reboot recovery
ADB Logcat command
This is one of the debugging commands. When you want to provide logs to your OEM or ROM developer, this command will help you. It will display current running status logs of your device which can be written into a file. Visit any development forums such as XDA and there’s a sure shot chance that you’ll find at least one developer asking users to provide logcat in case there is some problem. As the old saying goes, logcat or GTFO.
adb logcat > %PATH WHERE YOU WANT TO STORE THE LOG%
Example: The below command would create a file called Log.txt and add the status logs to it.
adb logcat > D:\Developer\Log.txt
ADB Sideload command
This command comes in handy when your OEM provides you the full zip of OTA packages. This is normal for Pixel, Nexus, and OnePlus owners They get the Beta versions in the ZIP format. With the sideload command, you can flash the OTA zips on your device and upgrade.
adb sideload %FILE PATH%
adb sideload C:\OnePlus\ROM\OxygenOS501BetaBuild.zip
Advanced ADB Commands
We have seen the basic ADB commands. Now it’s time to check out some advance level commands. These are usually used by developers to debug their applications. If you’re just another smartphone user, you probably won’t be using these commands. But, you never know when you might need to use one.
ADB Get-state command
Knowing the device state could be important at times. This particular ADB command helps you to get the current state of your device. So on typing the command, the result would be the current state of the device, Depending on the state of your device, it should return the following responses: device, recovery, sideload orfastboot. This generally is the boot state of the device, so if your device is booted into fastboot mode, you’ll get “fastboot” as a response.
ADB Get-devpath command
Sometimes you might need to know the device’s ADB path. The get-path command would help ADB on your PC find out the path of ADB on your device. Even if you are a developer you might not require this command on daily basis. However, there are chances that you might need it on some odd day. So knowing this would be handy.
ADB Remount command
The adb remount command will help ADB to remount the /system, /oem, and /vendor partitions in read-write mode on your device. However, a lot of users have reported that this command would work on a rooted device. Additionally, one would need to use ADB as root in order to use the remount command.
#Boot ADB as root adb root #Use the ADB remount command adb remount
ADB Forward command
The ADB forward command would help you in port forwarding. You might want to forward a request you receive on the host port 8080 to the device port 9000, you can simply use the command and get it done.
adb forward %local port% %remote port%
Example: The below example command would forward the requests received on the port 8080 to 9000.
adb forward tcp:8080 tcp:9000
ADB Reverse command
Adb reverse command is basically the opposite of adb forward. It allows you to forward ports from your device to the host. In this syntax, first parameter is the port on device which is remotely connected and second is the port on host you want to forward it to.
adb reverse %device port% %host port%
adb reverse tcp:8081 tcp:8081
ADB Sync command
adb sync is a command which is used to synchronize data between computer and device if the same data has been modified in PC. By default, the command will synchronize /data and /system files. For the command to operate properly, a system variable $ANDROID_PRODUCT_OUT must be created and defined. adb sync is commonly used when you build a ROM from Android platform source. So mostly it’s the ROM developers that will be using this command.
$ANDROID_PRODUCT_OUT= %Output Path% adb sync
$ANDROID_PRODUCT_OUT=/out/target/device/oneplus3 adb sync
ADB Backup command
The Adb backup command helps you to take entire backup of your device. There are multiple options you shall use, so if you want to take the backup of all the installed APKs on your device you can use -apk option. By using the -shared option, you’ll be able to take the backup of the external storage device as well. You can use the -all option to backup all the files, however, using -all won’t backup the APKs. Once you fire this command, your device will show a window to set a password for this backup as an added level of protection. Upon setting the password, backup file will be saved in the path you have provided. Note down the password, you might need it while restoring.
adb backup %Path to the folder where you want to keep backup with a file name% #If you don't enter the PATH or FILENAME, it'll by default be named as backup.adb
adb backup -all -f C:\device backup\fulldevicebackup.adb
ADB Restore command
The flat file backup which is taken using adb backup command can be restored to the device with adb restorecommand. We have to pass the path of the backup file as a parameter. Upon entering the password you have set at the time of backup, you can successfully restore it on your device.
adb restore %Path to the folder where .adb file is located%
adb restore C:\device backup\fulldevicebackup.adb
ADB Bugreport command
Just like adb logcat, this command is also used for debugging. A bug report output will have device logs, stack traces, and other diagnostic information to help you find and fix bugs.
adb bugreport %PATH where you want to save the report%
adb bugreport E:\Bugs\MyBugReports
ADB Disable-verity & ADB Enable-verity commands
DM-verity is a security measure to check the integrity of your device. The Disable-verity command will disable dm-verity protection which lives in the kernel. Disabling dm-verity will retain kernel modifications by bypassing this protection. So if a rooting software compromises the system before the kernel comes up, it will retain those modifications. The enable-verity will enable the protection if it is disabled in a user debug build. These commands are generally used by ROM developers for user debug builds.
#To Disable DM-verity adb disable-verity #To Enable DM-verity adb enable-verity
ADB Keygen command
The adb keygen command creates an adb public/private key pair in a user-specified file. This is also used to create new adb keys or rotate existing keys. RSA key pair is needed when we use adb to connect using USB for the first time. You have to accept the host computer’s RSA key to explicitly grant ADB access to the device. The extension of the file name is generally .pub.
adb keygen %filename%
adb keygen C:/android/keys/key.pub
ADB Root and ADB Unroot commands
This command is used to elevate the privilege of ADB. With adb root command, ADB will be restarted with root privileges. If you’ve gone through the adb remount command explained above, you might have seen that a remount wasn’t possible without ADB having root privilegs. There are many other things or commands where you might be required to use ADB as root. If you want to start ADB without root privileges, you can use the adb unroot command can be used.
#To use ADB with root privilege adb root #To stop using ADB with root privilege. adb unroot
ADB Start-server and Kill-server commands
The adb start-server command is used to check the current state of ADB server. When you start ADB or execute an ADB command for the first time, it automatically executes the “adb start-server” command (you might not see the execution, because it happens in the background.) So if there is an ADB server which is already live you might have to stop the current ADB server process by using the adb kill-server command. You shall use the start-server command to start ADB server after killing it.
#To stop/kill ADB server adb kill-server #To start a ADB server after killing it adb start-server
The above ADB commands list isn’t complete or final, it doesn’t include all the ADB commands. We’ve not mentioned the options too. However, we’ve given enough description of the commands with our personal understanding. You won’t be able to find a lot of things we’ve described in the original documentation as well. However, we do plan to add all the commands to this list in the future. Not only that, we also plan to create complete guide of every individual command with options in the future. Did we miss out some ADB command? Do comment the command we’ve missed and we’ll add it during our next update to this list. You can also get in touch with us on our Facebook Page