The complete list of ADB and Fastboot Commands

We use ADB and Fastboot commands to manage Android Partitions and Operating systems in our daily life. In this post, I describe some commonly used ADB and Fastboot Commands. Before that let us see some definitions and terms about them.

What is ADB?

Android Debug Bridge (ADB) is a handy command-line tool that grants you to interact with an Android device. The ADB command supports a variety of device actions, such as installing and debugging apps, and it provides access to a Unix shell that you can use to run a variety of commands on a device.

What is Fastboot?

Fastboot tools help to manipulate and flash the partitions of the Android phone. It can also boot the phone using a kernel image or root filesystem image which resides on the host machine rather than in the phone flash.

The Complete list of ADB and Fastboot commands

These commands are used for general purposes like installing custom recovery, custom ROM, rooting devices by magisk, etc.

Screenshot 07 22 2021 18.53.54

ADB and Fastboot Commands

ADB Commands

  • adb devices
    This is the basic adb command that used to list all the devices connected to the computer, and debugging is enabled. If you are entering the ADB command for the first time, then it will prompt to allow debugging on your phone. So you must allow it to use ADB commands to your phone.
  • adb –help 
    You can use this command to get help related to ADB like some ADB commands, shortcuts, and more.
  • adb sideload <file> 
    This adb command used to sideload any file to the device. The file name must be complete with its extension.

ADB reboot commands

  • adb reboot 
    You can use this command to reboot your phone without using the power button. It can be used when any modification requires a reboot.
  • adb reboot bootloader 
    As you know, to use fastboot commands, you have to boot your device into bootloader/fastboot/download mode. So this is the command that will boot your device into the Fastboot mode. After this adb command, you can use any fastboot command to modify your device.
  • adb reboot recovery 
    With this command, you can boot your Android phone to the stock recovery or custom recovery. You can also boot your phone into recovery using key combinations, but that is more complicated as the combination varies as per devices.

ADB install commands

  • adb install <file path>
    This command is for installing apps on the phone directly through the computer. Here <file path> means the location and name of the APK. So after adb install, just drag and drop the apk file, and it will pick the location and file name.
  • adb install -t <file path>
    Just like the above command, you can use this ADB command to install an app to the phone but for testing only.
  • adb install -r <file path> 
    If you want to reinstall any existing apps on your phone, then insert -r in the normal install command.
  • adb install -f <file path> 
    It will install the app to the internal storage of the phone.

ADB shell commands

  • adb shell 
    The shell command will enable the Linux terminal interface on your command window to control your connected Android phone. It allows us to enter Linux commands to interact with the device.
  • adb shell pm uninstall com.example.myapp 
    This is the adb command for uninstalling any existing apps on your phone. Here com.example.myapp refers to the package name of the app that you want to uninstall. So make sure to replace com.example.myapp with the correct package name. This is a helpful command if you want to remove bloatware or pre-installed apps.
  • adb shell pm uninstall com.example.myapp 
    To uninstall any app while keeping its data and cache in the storage.
  • adb clear com.example.myapp 
    It will remove all the data and cache related to the package.
  • adb shell screencap <screenshot location>
    If you want to take a screenshot of the current screen of your phone, then you can use this ADB command. Replace the <screenshot location> with the location and file name where you want to save your screenshot like /sdcard/screenshot.png.
  • adb shell screenrecord <screenrecord location>
    Similar to the screenshot, you can also record the screen of the phone with ADB command. Make sure to replace <screenrecord location> with the location & extension where you want to save the screen recording file. For eg. /storage/emulated/0/Download/screenrecord.mp4. To stop screen recording, press Ctrl+C.

Some other ADB commands

  • adb push <file source> <file destination> 
    The adb command used to copy the <file source> from your computer to the <file destination> on your phone. It can be used if you want to transfer any file from the phone without drag and drop. Replace <file source> with file directory where your file is existing and <file destination> with the location where you want to save the file.
  • adb pull <source> <destination>
    It is the same command as adb push but to copy files from phone to computer.
  • adb logcat 
    You can use this command to display the real-time log of your phone.
  • adb logcat > logcat.txt 
    To save the captured real time log to file logcat.txt.
  • adb remount 
    If the system partition of your phone is set to Read-Only, but you want to mount it as Read/Write, then this adb command can be used.
  • adb kill-server 
    The command used to kill the adb process.
  • adb start-server 
    To restart the adb server after killing the process with the above command.
  • adb connect <device IP address> 
    To connect the phone with WiFi along with Debugging access.
  • adb forward tcp:7100 tcp:6100 
    ADB command to forward the host port from 7100 to 6100. Just replace the port number with another port that applies in your case.

Fastboot Commands

Fastboot reboot commands

  • fastboot devices 
    This fastboot command will list the devices connected to the computer in fastboot mode.
  • fastboot reboot 
    To reboot your device back into the fastboot/bootloader mode. Remember fastboot command will only work if your phone is in Fastboot mode that can be achieved using adb reboot bootloader command.
  • fastboot reboot recovery 
    Entering this fastboot command will boot into Stock or custom recovery. We generally use this command after flashing recovery image with fastboot command.

Fastboot oem commands

  • fastboot oem unlock 
    The command used to unlock bootloader on Google phones and some other phones. It will only work with supported phones.
  • fastboot oem lock 
    Like unlock, you can also use the fastboot command to relock the bootloader of many Android phones.
  • fastboot oem device-info 
    This fastboot command will help us to see the bootloader status. It will return ‘True’ if bootloader unlocked and return ‘False’ if bootloader locked.

Fastboot flash/flashing commands

  • fastboot flashing unlock 
    This one is also used to unlock bootloader but for different devices like the new Pixel phones released after 2015.
  • fastboot flashing unlock_critical 
    It is also used to unlock bootloader for a different condition like updating bootloader, and updating phones manually.
  • fastboot flashing lock 
    To relock bootloader of newer phones, this fastboot command can be used.
  • fastboot flashing lock_critical 
    It can be used to relock bootloader if you have unlocked using the unlock_critical command.
  • fastboot flash boot boot.img 
    You can use this fastboot command to flash boot image files. It is generally used when the phone is stuck in the boot loop due to a corrupt boot image. And also, the command used to root Android phones after patching the boot image file. Make sure to rename your boot file to boot.img.
  • fastboot flash recovery recovery.img 
    If you want to flash stock recovery or a custom recovery, then this fastboot command is used. Before entering the command, rename the recovery image file to recovery.img.
  • fastboot flashall -w 
    The fastboot command used to wipe the /data partition on the device.
  • fastboot flash system system.img 
    You can flash the system image file using the command. The system image can be found in the Firmware of the phone.
  • fastboot flash userdata data.img 
    Similar to the last fastboot command you can also flash user data image.
  • fastboot flash zip file.zip 
    It can be used to flash zip files like custom ROM. Replace the file.zip with the file name you want to flash.

Fastboot boot commands

  • fastboot boot recovery.img 
    You can use this fastboot command to boot the phone into recovery temporarily. Replace the recovery.img with the recovery file name.
  • fastboot boot kernel ramdisk 
    For developers who are working on the custom kernel can use the fastboot command to test the kernel.

Fastboot erase commands

  • fastboot erase data 
    If you want to clean flash any ROM then you can use this fastboot command to erase phone data.
  • fastboot erase system 
    To erase the system from your phone before flashing a custom ROM.
  • fastboot erase cache 
    To delete all cache from the phone.
  • fastboot erase system -w 
    This fastboot command will erase System, data, and cache in one command. So it is the combined command for the previous three commands.

Other Fastboot commands

  • fastboot getvar mid 
    This fastboot command used to get the device model number.
  • fastboot getvar all 
    It will give more information about the device like device model, radio, IMEI, etc.
  • fastboot format:ext4 userdata 
    It can be used to delete/wipe all the data from the ext4 partition. Change the partition if you want to delete data from other partitions.

Commands to install twrp

  1. Reboot your device to Bootloader Mode. Connect your Mobile to PC by USB cable.
  2. Now type command fastboot devices . It shows whether your device is connected or not
  3. fastboot flash recovery <filename.img> . flashing/installing twrp in recovery
  4. (or) if you have to install twrp in boot, then: fastboot boot <filename.img>

How to use ADB and Fastboot commands?

Use of ADB Commands
Generally, we use ADB commands in CMD for the Operating System to install and manage applications, debug apps, tweak device software, etc in one phase. In another phase, we use ADB commands in Recovery Partition to manage device OS.

Use of Fastboot Commands
We use Fastboot commands in Fastboot mode to manage and tweak several Android Partitions.

We can use ADB and Fastboot commands in CMD by connecting an android phone to a PC via a USB data cable.

steps to enable ADB connection in Android phone

  1. Install ADB and Fastboot tool in your PC.
  2. Install Required USB drivers. (Skip step: 1 & 2 If you have already installed)
  3. Enable the developer options in Phone.
  4. Enable USB Debugging.
  5. Connect your phone to PC via USB data cable.
  6. Open Terminal/ Command prompt/ CMD in your PC.
  7. type the command: ADB devices
  8. Now a popup appears on your phone. Allow it.

How ADB is different from Fastboot?
If fastboot is the main Gateway to an Android device then ADB is like a window to the device. In most cases, ADB commands are used to manage OS’s software and Fastboot commands are used to manage the device’s system and its partitions.

Why Bootloader is locked in Android?
Since ADB and Fastboot are pathways to an Android device. So anyone can enter into your device via them. So in order to avoid this, your device’s bootloader is locked by birth itself, and you need to unlock it as per your needs.

But unfortunately, the device stealer can still Bypass these. And this is why users choose iOS over Android. But believe me, iOS is like heaven in Prison. Sorry APPLE, Hahaha…!

Guide to install ADB and Fastboot

Guide to install 15 seconds ADB installer

Guide to install Minimal ADB and Fastboot

Warning

If you are a beginner, then try these under the guidance of a dev. I am not responsible if you brick your device.

Leave a Reply

Your email address will not be published.