We have created a list of ADB and Fastboot commands for Android, Windows and Mac.



The long-form for ADB is the Android debug bridge. As the name suggests it is a tool that connects communication between an Android device and a personal computer.

A USB cable is required for setting up this communication. However, Wi-Fi connections can also be used for the same.

adb shell commands

Installing ADB and fastboot.

Different devices need different instructions for the installation of ADB and fastboot. A step by step process for installing fastboot on Windows, macOS and Linux are given under :

On Windows 

  1. First download Windows zip which is available on Google.
  2. Then it needs to be extracted
  3. There is a slight difference for download on Windows 7/8 and 10. Hence we will discuss them separately.

Windows 7/8

  • Select properties in My Computer
  • Select the Advanced tab in the system properties
  • Then click the Environment variables button
  • When the environment variables window opens click on the systems variable section, highlight the path variable and click on the edit button
  • At the end of the current path, add –

  ;%USERPROFILE%\ADB-fastboot\platform-tools 

Windows 10

  • In the start, menu search advanced system settings
  • Then View advanced system settings
  • In the advanced tab click on environment variables window
  • When the environment variables window opens click on the systems variable section, highlight the path variable and click on the edit button
  • At the end of the current path, add  

;%USERPROFILE%\ADB-fastboot\platform-tools

  1. This is the last step common for both the systems. After all the above steps are properly done you can install a universal ADB driver. Don’t forget to restart the system after the installation.

On macOS

  1. First download macOS zip which is available on Google
  2. Then it needs to be extracted
  3. To ~/.bash_profile append the following

if [ -d “$HOME/ADB-fastboot/platform-tools” ] ; then

 export PATH=”$HOME/ADB-fastboot/platform-tools:$PATH”

fi

  1. Universal ADB drivers can now be installed. After the installation is complete, restart the system

On Linux

  1. First download Linux zip which is available on Google
  2. Then it needs to be extracted
  3. To  ~/.profile append the following text

if [ -d “$HOME/ADB-fastboot/platform-tools” ] ; then

export PATH=”$HOME/ADB-fastboot/platform-tools:$PATH”

fi

  1. The installation gets completed after the system is restarted

Setting Up ADB

Following is the step by step process to set up ADB in your device

  1. First select about from settings
  2. Then tap 10 times on “Build Number”
  3. Select developer options once you go back to settings
  4. Under debugging tab click on USB debugging or android debugging or ADB debugging option
  5. Drivers on the PC can be installed on the system by clicking on Run and following the instructions. Pda.net can be a help for the same
  6. Type cd/ADB in the command prompt. A path such as C:\ADB> appears
  7. Again in command prompt type ADB devices. Your system name appears in the list
  8. By typing ADB reboot bootloader, the system goes on bootloader mode

Setting up Fastboot

If you want to use fastboot, when rebooting the system just involve fastboot mode. Once you are in Fastboot mode then the device can be detected by just typing fastboot devices.

Now your system is ready to send the command to your phone by using ADB or fastboot. The only thing that needs to be noted here is that the file that needs to be shared has to be saved in “ADB” folder of the system . only then the command to send the file can be given.

Unlocking bootloader using ADB or fastboot

Following are the steps to unlock bootloader using ADB or fastboot

  • By shift + right-click in the ADB folder a command line window opens
  • By typing ADB devices in the command prompt, your device is detected
  • First type ADB reboot bootloader and then fastboot oem unlock
  • Then you will get a prompt window asking if you want to unlock. Click yes and the bootloader will be unlocked.
  • After this, recovery needs to be flashed
  •  By shift + right-click in the ADB folder a command line window opens
  • By typing ADB devices in the command prompt, your device is detected
  • First type ADB reboot bootloader
  • After this type fastboot flash recovery (name of the recovery.img). But before this check that the recovery.img is copied to ADB folder on the sytem

Logcat

When the device shows an error and a message is flashed that you have written from your app with the log class, then the command line that dumps a log of system messages is known as logcat. This also includes stack traces. The android device needs to be connected to the laptop for viewing logcat.

The command for taking a logcat is 

ADB logcat –vlong >logcat.txt

Or 

ADB logcat > logcat.txt

Importance of ADB commands and Fastboot mode

ADB command is a multifaceted command-line tool. It helps in communicating with other devices. Along with this it also facilitates a wide variety of actions on the other devices like Installing and debugging apps. This command-line helps in getting access to Unix shell which in turn can be used to run as many commands as needed on a device.

Fastboot mode is a kind of protocol that is used to reflash partitions on the device. This small tool comes with an Android software developer kit. For doing installations and updates the fastboot mode is used as an alternative to the recovery mode.

Uses of ADB and fastboot commands

The ADB commands and fastboot is the most useful tool that is available. The device is managed very efficiently with ADB commands. Following are some of its uses :

  • It helps in rebooting the device even in recovery mode and bootloader mode
  • The files can be copied from the computer to the phone
  • The files can also be copied from phone to computer
  • Apps can be remotely installed removed or updated with the help of these commands
  • A full back up of the phone can be created and saved on the computer

Popular ADB Commands

Following is the list of popular ADB commands

  • ADB shell – this command launches a shell on the device
  • ADB push <local> <remote> – this command pushes the file from local to remote folder
  • ADB pull <remote> [<local>] – this command pulls back the file from remote to a local folder. If a local folder is not identifiable, then it will pull to the current folder.
  • ADB logcat – this command allows you to extract the device log in real-time.  ADB logcat -b radio is used to extract radio logs, and ADB logcat -C is used to extract logs in color
  • ADB install <file> – the given .apk file is installed to your device with this command
  • ADB devices –This command  lists all the connected devices
  • ADB sync [ <directory> ] – the command is used to copy host device only if changed
  • ADB shell <command> – this command is used to run a remote shell command
  • ADB emu <command> – the command runs emulator console command
  • ADB forward <local> <remote> – this command forwards socket connections
  • ADB jdwp – this command is used to list PIDs of processes hosting a JDWP transport
  • ADB install [-l] [-r] [-s] <file> – This command is used to push the package file to the device and install it
    (here ‘-l’ implies forward-lock the app)
    (here ‘-r’ implies reinstall the app, keeping its data)
    (here ‘-s’ implies install on SD card instead of internal storage)
  • ADB uninstall [-k] <package> – This command removes the app package from the device
    (here ‘-k’ implies keep the data and cache directories)
  • ADB bugreport – this command is quite helpful in returning all information from the device that should be included in a bug report.
  • ADB help – This command shows the help message
  • ADB version – this command shows version num
  • ADB wait-for-device – this command blocks until the device is online
  • ADB start-server – this command ensures that the server is running
  • ADB kill-server – this command stops the server if it is running
  • ADB get-state – this command prints offline 
  • ADB get-serialno – this command is used to print serial-number
  • ADB status-window – this command is used to continuously print device status for a specified device
  • ADB remount – this command remounts the system partition on the device read-write
  • ADB reboot [bootloader|recovery] – this command is used to reboot the device, optionally into the bootloader or recovery program
  • ADB reboot-bootloader – this command reboots the device into the bootloader
  • ADB root – This command is used to restarts the ADBd daemon with root permissions
  • ADB usb – this command is used to restart the ADB daemon listening on USB
  • ADB tcpip <port> – this command restarts the ADBd daemon listening on TCP on the specified port
  • ADB ppp <tty> [parameters] – this command Runs PPP over USB.
    It is important to note here that you should never automatically start a PPP connection.
    Here “ tty” refers to PPP stream.
  • ADB_TRACE – This command prints debug information. 

A comma is used to separate list of the values of ADB, sockets, packets, rwx, usb, sync, sysdeps, transport, jdwp

  • ANDROID_SERIAL –If this command is given then the serial number to connect to. -s takes priority.
  • ANDROID_LOG_TAGS – When this command is used with the logcat option, only the debug tags are printed

Fastboot Commands

Following list shows some of the popular fastboot commands

  • update <filename> – this command reflashes device from update.zip
  • flash <partition> [ <filename>]- this command writes a file to a flash partition
  • erase <partition> – this command erases a flash partition
  • getvar <variable> – this command is used to display a bootloader variable
  • boot <kernel> [ <ramdisk> ] – this command downloads and boot kernel
  • flash:raw boot <kernel> [ <ramdisk> ] –  this command creates boot image and flash it