Useful ADB and Fastboot Commands and How to Use them

17

ADB an official tool by Google – you must have heard of it if you have ever come across Android development or flashing processes. Stands for Android Debug Bridge basically and helps you to establish a connection and communicate between your phone and your computer. ADB has a command-line interface, which helps the developers/programmers/users to enter commands and do the stuff they want. ADB also plays an important role when you don’t have access to certain things on your phone, you can simply handle the problem through the command window.

Earlier we posted a guide on “How to Install and Use Android ADB & Fastboot” but missed the important ADB commands that may become handy in some cases, and found necessary to cover them now. In case you’re wondering about Fastboot, it’s a component of ADB that helps you to flash files or make tweaks by accessing Fastboot mode on your device. Well, let’s get back to the topic. In the following post, I’ve listed the useful ADB commands, and also explained their use.?????????????

You may want to install Android ADB and Fastboot, and also learn how to use the program actually please go through this guide:

Useful ADB & Fastboot Commands

CommandsUse
Basic ADB Commands
adb devicesShows a list of devices attached to the computer.
adb rebootReboots a device connected to the PC.
adb reboot recoveryReboots a device into recovery mode.
adb reboot downloadReboots the connected device into download mode. E.G Download mode on Samsung Galaxy devices.
adb reboot bootloaderReboots a device into Bootloader. Once in Bootloader, you can make further selections here.
adb reboot fastbootReboots a connected device into Fastboot mode.
Installing / Uninstalling / Updating Apps with ADB. 
adb install .apkADB install let's you install APK files directly to your phone. To use this command type adb install application path, as shown in the commands part and hit enter key and it will start installing the app on your phone. e.g adb install C:/Users/UsamaM/Desktop/CandyCrushSaga.apk. If process succeeds it will show you "Success" in the command window.
adb install -r .apkIf you have already installed an app, and you just want to update it then this command will let you do so. e.g adb install -r C:/Users/UsamaM/Desktop/CandyCrushSaga.apk
adb unistall package_namee.g

adb uninstall com.android.chrome
Uninstalls and application from your device. The easiest way to find a package name is, install Package Name Viewer from the play store and find the name of the package under the App Name. If process succeeds it will show you "Success" in the command window.
adb uninstall -K package_namee.g

adb uninstall -K com.android.chrome
Uninstall an app but keeps it's data and cache directories. If process succeeds it will show you "Success" in the command window.
 Push and Pull files 
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
the adb push commands you transfer any files to your phone from your PC. You simply need to provide the path of file on your PC and path where to place this file 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]
Similar to the adb push command. Using adb pull, you can simply pull any files from your phone.
Backing up system and installed apps. 

Before doing this, in your adb folder create a folder Backup and under the backup folder create two folders named SystemApps and InstalledApps.

These folders are necessary as you'll be pushing the backed up apps to these folders.
adb pull /system/app backup/systemapps backs up all the system apps of your phone to the Systemapps folder that you created in the ADB folder.
 adb pull /system/app backup/installedapps backs up all the installed apps of your phone to the installed apps folder that you created in the ADB folder.
  Background Terminal
 adb shell starts the background terminal.
exitexits the background terminal.
adb shell e.g adb shell suswitches to the root of your phone. Please make sure that you're rooted in case you wish to use adb shell su.
Fastboot commands

To flash files using fastboot, place the desired files in Fastboot folder or Platform-tools folder that you obtained after installation of Android SDK tools.
Fastboot Flash File.zip Flashes a .zip file to your phone, when your phone is connected in Fastboot mode.
Fastboot Flash recovery recoveryname.imgFlashes a recovery to your phone when it's connected in Fastboot mode.
Fastboot flash boot bootname.imgFlashes a boot or kernel image when your phone is connected in Fastboot mode.
Fastboot getvar cidshows you the CID of your phone.
Fastboot oem writeCID xxxxxwrites the super CID.
fastboot erase system

fastboot erase data

fastboot erase cache
In case you want to restore a nandroid backup, you'll have to delete the current system/data/cache of your phone first. Before doing this, it is always recommended to have backed up your system using a custom recovery>backup option and copy the backed up .img files to Fastboot or Platform-tools folder in Android SDK folder. Then performing these commands will erase everything.
fastboot flash system system.img

fastboot flash data data.img

fastboot flash cache cache.img
These commands will restore the backup that you made using a custom recovery on your phone and placed in the Fastboot folder under Android SDK tools.
fastboot oem get_identifier_token

fastboot oem flash Unlock_code.bin

fastboot oem lock
These commands help you to get the identifier token of your phone that can be used for unlocking the bootloader. The second command helps you to flash the bootloader unlock code, and the 3rd commands help you to lock your phone's bootloader once again if locking it is actually allowed.
Logcat
adb logcatShows you the real-time logs of your phone, these logs represent the ongoing process on your device. It is recommended that you run this command while your device boots up to check what's going on.
adb logcat > logcat.txtCreates a .txt file containing the logs in the Platform-tools folder or Fastboot folder in Android SDK tools directory.
Here is a complete list of all the important and useful ADB & Fastboot Commands.

That’s all for now. We may be missing a lot of commands, those may be added later. In case you got any suggestions, queries or face any difficulties, please feel free to stop by the comment box below and drop your words. We will get back to you as quick as we can. Thanks All!

SHARE
Usama is a software engineer by profession and at TechBeasts.com he uses his expertise to solve everyday consumer tech problems with his main areas of interest being Android, iOS and Windows.

17 COMMENTS

  1. Is it possible to execute a fastboot bat install script from a Windows 8.1 computer? The bat scrip in question is a fastboot install script for my Xiaomi MiPad but the GUI that is supposed to flash it doesn’t work properly so I am looking for a manual option to run it in fastboot.

    The GUI did manage to install device drivers so I can connect properly ADB and Fastboot.

    If it is possible to run a script manually in fastboot then adding this command to your list would be most useful and you would earn my undying gratitiude :=)

    • @disqus_VmwZ4lsKKO:disqus you will have to look actually what commands that bat script runs, there might be a way to run it using the manual adb and fastboot. Also, if you’re having problems running bat script on a windows 8.1 computer, you will need to resolve the issue. I haven’t done a guide for that yet, but ADB and Fastboot do not easily get configured on windows 8.1.. until windows 8, it was just fine.. however, stay connected, I shall find a method and let you know soon.

      • Hey thanks for the input! Will stay connected. I can post the script maybe?

        (By the way reboots me into fastboot mode as my version of adb only has reboot and reboot-bootloader else a space after reboot is immediately executed as normal reboot. Maybe Google have simplified commands in new versions of adb?)

        • @disqus_VmwZ4lsKKO:disqus Which ADB and Fastboot drivers are you using? The current version is using the commands listed above, and Minimal ADB and Fastboot uses the same commands as well.

  2. Are you aware you stated the exact same command under “backing up system and installed apps” for backing up system and what you call “installed” apps. The command you meant to copy and paste there replaces system with data. Like this adb pull /data/app backup/installedapps

  3. Can Formatted OS be recover in Micromax Doodle A111?

    I have Micromax Doodle A111 and while attaching it to PC i press both the buttons (Power on/off & Voice) and on pc i got pop up to format Drive E and mistakely i formatted the same & Now Mobile is not getting on and not even getting detected to PC. is there any solution to repair the same.

    Please update any help if possible to it……………………..

  4. i hvave moto x gen 1(MOTO XT1052) It is stuck in loop it dose not even open the recovery. If i try to open recovery it just keep on restarting.
    Even though i installend new recovery still the problem is same.Please help me out.

  5. UNABLE TO RECOVER STOCK OS OF HTC DESIRE X AFTER INSTALLING CUSTOM ROM. I WANT TO GET BACK TO MY OLD OS , BUT I CAN’T .PLEASE HELP. i also did a nandroid backup. when i try to recover then it goes in bootloop

  6. Hi all. I’m trying to uninstall an app from my LG G7 ThinQ via the ADB. I got my phone stuck in an endless loop because I accidently turned on “resume running automations on start up” in my automation app. Now I’m stuck in a forever hitting of the back button and I’m unable to open ANYTHING. I tried restarting in safe mode, but it’s not working. I believe it my be because I have my phone encrypted for added security.

    Anyway, I tried using the ADB and the commands above, and in another article I read here, but it just keeps saying :

    “PS C:FastBoot> .adb uninstall com.llamalab.automate_2019-02-03.apk
    * daemon not running; starting now at tcp:5037
    * daemon started successfully
    error: no devices/emulators found
    – waiting for device -”

    My device is connected, it’s in fastbood mode. I checked every step thrice….. I’m stuck and I’m getting desperate lol. can any one help?

    Thank you for your time and consideration.

    [email protected]

    • @seangarren:disqus I believe your phone is still in bootloop. Here are your options now.
      Boot into recovery and clear cache. If cache doesn’t help, perform a factory reset. If the factory reset fails too, the only option is to flash a new stock firmware using the LG flash tool.

Got a question/query or a suggestion? Drop it below.