Useful ADB And Fastboot Commands
ADB is an official Google tool for use in Android development and the flashing process. ADB stands for Android Debug Bridge and this tool basically allows you to establish a connection between your phone and a computer so you can communicate with the two devices. ADB uses a command line interface, you can enter commands to do what you want.
In this post, we’re going to enumerate and explain some important ADB commands that you might find useful to know. Take a look at the tables below.
Basic ADB Commands:
Command | What it does |
adb devices | Shows you a list of devices that are attached to the PC |
adb reboot | Reboot a device that is connected to the PC. |
adb reboot recovery | Will reboot a device into recovery mode. |
adb reboot download | Will reboot a device that is connected to the PC into download mode. |
adb reboot bootloader | Will reboot a device into bootloader. When in bootloader you will be allowed to choose further options. |
adb reboot fastboot | Will reboot a conneted device to Fastboot mode. |
Commands for installing/uninstalling/updating apps using ADB
Command | What it does |
adb install<ApplicationpathPackagename>.apk | ADB allows for the installation of APK files directly on a phone. If you type in this command and hit the enter key, ADB will begin installing the app on the phone. |
adb install –r <ApplicationpathPackagename>.apk | If an app has already been installed and you just want to update it, this is the command to use. |
adb uninstall -K package_namee.g
adb uninstall -K com.android.chrome |
This command uninstalls an app but keeps the app’s data and cache directories. |
Commands to push and pull files
Command | What it does |
adb rootadb push >e.gadb push c:\users\UsamaM\desktop\Song.mp3 \system\media
adb push filepathonPC/filename.extension path.on.phone.toplace.the.file |
This push command allows you to transfer any files from your phone to your PC. You just need to provide path for the file that is on your PC and the path where you want the file placed on your phone. |
adb rootadb pull>e.gadb pull \system\media\Song.mp C:\users\UsamaM\desktop
adb pull [Path of file on phone] [Path on PC where to place the file] |
This is similar to the push command. By using adb pull, you can pull any files from your phone. |
Commands to back up system and installed apps
Note: Before using these commands, in the ADB folder create a Backup folder and in the backup folder create a SystemsApps folder and Installed Apps folder. You will need these folders as you are going to be pushing backuped apps in them.
Command | What it does |
adb pull /system/app backup/systemapps | This command backs up all system apps found on your phone to the Systemapps folder that was created in the ADB folder. |
adb pull /system/app backup/installedapps | This command backs up all installed apps of your phone to installedapps folder that was created in the ADB folder. |
Commands for Background Terminal
Command | What it does |
adb shell | This starts the background terminal. |
exit | This allows you to exit the background terminal. |
adb shell <command you want>e.g adb shell su | This switches you to the root of your phone. You need to be to use adb shell su. |
Commands to Fastboot
Note: If you are going to flash files using fastboot, you need to place the files to be flashed in either the Fastboot foler or the Platform-tools folder that you get when you install Android SDK tools.
Command | What it does |
Fastboot Flash File.zip | This command flashes a.zip file in your phone, if your phone is connected in Fastboot mode. |
Fastboot Flash recovery recoveryname.img | This flashes a recovery to a phone when it is connected in Fastboot mode. |
Fastboot flash boot bootname.img | This flashes a boot or kernel image if your phone is connected in Fastboot mode. |
Fastboot getvar cid | This shows you your phone’s CID. |
Fastboot oem writeCID xxxxx | This writes the super CID. |
fastboot erase system
fastboot erase data fastboot erase cache |
If you want to restore nandroid backup, you need to first delete the phones current system/data/cache. Before you do this, it is recommended that you have backed up your system with a custom recovery>backup option and have copied the backed up .img files to either the Fastboot or Platform-tools folder in Android SDK folder.. |
fastboot flash system system.img
fastboot flash data data.img fastboot flash cache cache.img |
These commands restore the backup you made using custom recovery on your phone. |
fastboot oem get_identifier_token
fastboot oem flash Unlock_code.bin fastboot oem lock |
These commands will help you get the identifiertoken of a phone which can be used for unlocking the bootloader. The second command will help to flash the bootloader unlock code. The third command helps you to re-lock the phone bootloader. |
Commands for Logcat
Command |
What it does |
adb logcat | Will show you the real time logs of a phone. The logs represent the ongoing process of your device. You should run this command while your device boots up to check what is happening |
adb logcat > logcat.txt | This creates a .txt file containing the logs in either the Platform-tools folder or Fastboot folder in the Android SDK tools directory. |
Do you know any more useful commands for ADD?
Share your experience with us in the comments box below.
JR
[embedyt] https://www.youtube.com/watch?v=XslKnEE4Qo8[/embedyt]