Guides

A List Of Useful ADB And Fastboot Commands And Their Usage

install-android-bootloader-inter

This guide will cover all the essential ADB and Fastboot Commands that you need to know for custom development. Whether you are a tech enthusiast or a general user, these commands will help you perform various tasks on your device. ADB and Fastboot Commands are the basic steps to start your custom development journey.

Some common scenarios where these commands come in handy are: opening the ADB shell environment to perform tasks like removing unwanted apps, rebooting the device to stock recovery for factory resetting, or flashing firmware via ADB sideload. These are some of the basic everyday tasks that can be done with these commands.

ADB and Fastboot Commands are essential tools for Android development and customization. They allow you to perform various operations on your device, such as booting into different modes, unlocking the bootloader, flashing custom recovery, rooting, and more. In this guide, we will introduce some of the most important and useful ADB and Fastboot Commands that you should know. Let’s get started.

The Prerequisites to Executing ADB and Fastboot Commands

To use any of the ADB and Fastboot Commands, you need to meet some requirements before proceeding. These are essential to ensure the proper functioning and compatibility of your device and computer. The following list summarizes the prerequisites that you should verify.

1: Download Android SDK Platform Tools

To proceed with this guide, you need to get the Android SDK Platform Tools on your PC. This is the official source of ADB and Fastboot binary from Google and the only one we recommend. Download it and extract it to a location of your choice on your PC. You will get a platform tools folder, which we will use throughout this guide.

2: Enable USB Debugging

To proceed with the next step, you need to activate USB Debugging mode on your device. This will allow the PC to communicate with your device via ADB commands.

To do this, follow these instructions:

  • Go to Settings > About Phone > Tap on Build Number 7 times [MIUI number for Xiaomi devices] > Return to Settings > System > Advanced > Developer Options > Turn on USB Debugging.

Enable USB Debugging

3: Open CMD inside Platform Tools

  • Head over to the platform tools folder, type in CMD in the address bar, and hit Enter.

  • This will launch the CMD window with the platform-tools folder directory.
  • You should execute all the ADB and Fastboot commands only in this CMD window.

Most Commonly Used ADB Commands

Here are some of the important as well as the most widely used ADB Commands and their functions.

Check ADB Connection 

The following code will verify that the device is correctly connected and recognized by ADB. You need to see a device ID and the word ‘device’ in the output (refer to the screenshot below) before you can proceed with any other operations. Also, make sure that the device is not marked as ‘unauthorized’. If you encounter any issues, check out this article: Fix Waiting for Device Error in ADB Devices.

adb devices

adb devices

ADB Shell Command

The ADB shell commands let you perform some advanced operations on your device without needing root access. You can access the Shell environment by connecting your device to a computer and running the ADB tool. This way, you can customize some system settings or apply some tweaks that are normally restricted by the default configuration.

adb shell

To make sure that the command has been usefully executed, you should see your device name or ID right after entering this command.

Reboot to Bootloader/Fastboot Mode

  • Use the below command to boot the device to Fastboot or Bootloader Mode.

adb reboot bootloader

Reboot to TWRP or Stock Recovery

To boot your device to TWRP or stock recovery from the OS, use the below command. [Read More: How to Boot into Recovery (TWRP/Stock)]

adb reboot recovery

Pull Any File via ADB Pull

To ‘pull’ any file from your device and send it over to your PC, enter:

adb pull /file-location-on-device/filename

Push files via ADB Push

Similarly to ‘push’ any file to the device from a PC, type:

adb push filename /location-where-file-is-to-be-sent-on-device

ADB Sideload

Using this command, you could flash (install) ZIP files directly from the command shell. However, you could use it across both the stock and custom recovery like TWRP.

adb sideload filename.zip

Start ADB Server

When you need to start the ADB server, in case it does not automatically “kills the daemon” and “start on a specific port”, type the below command:

adb start-server

Kill ADB Server

If the command tool gets hanged or is not performing as expected, you may kill the server by entering the below code:

adb kill-server

Install APK via ADB Command

To install an APK file on your device, enter the below command:

adb install filename.apk

Update APK via ADB Command

To reinstall or update an APK, type:

adb install -r filename.apk

Move App to SD Card via ADB

To move the app to sdcard (if supported by your device):

adb install -s filename.apk

Uninstall App via ADB Command

To uninstall an APK file on your device, type:

adb uninstall filename.apk

Check Installed Apps via ADB

To list all the app packages’ name

adb shell pm list packages

Check System Apps via ADB

To list all the system apps:

adb shell pm list packages -s

Uninstall System Apps via ADB

To uninstall system apps or any bloatware:

adb shell pm uninstall -k –user 0 app-package-name

List All Third Party Apps via ADB

To list third-party apps installed:

adb shell pm list packages -3

Take a Screenshot via ADB

To capture screenshots from your device:

adb shell screencap /sdcard/screenshot.png

Then to download the captured screenshot to your PC:

adb pull /sdcard/screenshot.png

Delete File via ADB

To delete a file, type :

adb shell
rm -f /sdcard/OPWallpaperResources.apk

Deleter Folder via ADB

To delete a folder, enter the below code:

adb shell
rm -d /sdcard/ZooperWidget

Create New Folder via ADB

To create a new folder on your device, type:

adb shell
mkdir /sdcard/NewFolder

Copy Files via ADB

To copy a file from one location and paste it to another location (on your device), type:

adb shell
cp /sdcard/OPWallpaperResources.apk /sdcard/LiveWallpapers

Move Files via ADB

To move a file from one location to another (on your device), enter the below code:

adb shell
mv /sdcard/OPWallpaperResources.apk /system/app

Most Commonly Used Fastboot Commands

Here are some of the most commonly used as well as the most important Fastboot Commands and their functions.

Reboot to Fastboot Mode

To reboot your device to fastboot or bootloader mode, enter the below code:

adb reboot bootloader

Verify the ADB Connection

To verify the connection in fastboot mode, run the following command on your device. You should see a string of letters and numbers, followed by the word fastboot (see screenshot below). This indicates that your device is successfully connected in fastboot mode. You can now execute other fastboot commands as needed.

fastboot devices

fastboot devices

Unlock Bootloader via Fastboot

Before you attempt to unlock the bootloader of your device, you need to enable ‘OEM Unlocking’ from the ‘Developer Options’ menu. This will allow you to use one of the two codes below to unlock the bootloader. Be aware that this process will erase all your data, so make sure you have a backup ready. The first code is compatible with most devices, but if it doesn’t work for you, try the second one.

fastboot oem unlock
OR
fastboot flashing unlock

Relock Bootloader via Fastboot

To relock the bootloader of your device, enter:

fastboot oem lock

OR

fastboot flashing lock

Boot to TWRP via Fastboot

To boot a recovery file on your device, enter the below code:

fastboot boot recovery twrp.img

Install File to Boot Partition

To flash (install) a boot file from the command shell,

fastboot flash boot boot-file-name.img

Install TWRP to Boot partition

If your device does not have a recovery partition, then you will have to flash TWRP in the boot partition, using the below command

fastboot flash boot recovery-name.img

Erase Userdata

To erase all the userdata on your device (i.e.formatting the userdata partition), enter the following code:

fastboot erase userdata

Erase Everything via Fastboot

This will erase everything from your device. Your device will be just as it came out of the box

fastboot -w

Check Current Active Slot

If you have a dual A/B Partition device, then you could check the current active partition via the following command:

fastboot getvar all

After executing this command, refer to the (bootloader) current-slot: section.

Change Active Partition

If your device is A/B Partition, and you want to switch slots, say from A to B, type the below command:

fastboot set_active b

Reboot to OS from Fastboot

To reboot your device to Android OS, enter the below code:

fastboot reboot

Reboot from Fastboot to Recovery Mode

To Reboot from Fastboot to Recovery Mode, either TWRP or stock, use the below command:

fastboot reboot recovery

fastboot oem reboot-recovery

Boot to FastbootD Mode

To boot the device to the newer FastbootD Mode, use the below command.

From ADB: adb reboot fastboot

From Fastboot Mode: fastboot reboot fastboot

How to Fix All Possible ADB and Fastboot Errors

ADB and Fastboot commands are powerful tools that can perform various tasks on your Android device. However, they are not flawless and sometimes you may encounter errors or issues while using them. Don’t worry, most of these problems can be solved easily with some simple steps. I have created different guides for different ADB and Fastboot errors and how to fix them. I have also written a comprehensive guide that covers all the common ADB and Fastboot fixes. Let’s take a look at them:

Leave a comment

Your email address will not be published. Required fields are marked *

You may also like

Samsung Smart Switch Software
Flash Tool Guides

How To Install Samsung Smart Switch Software

Samsung Smart Switch is a convenient management tool for your Samsung Galaxy device. It allows you to seamlessly transfer, copy,
Update Samsung Software Via Samsung Smart Switch
Flash Tool Guides

How To Update Samsung Firmware Via Samsung Smart Switch

Samsung Smart Switch is a highly useful program offered by Samsung, available for both PC and Mac computers. This software