List of useful ADB and Fastboot commmands for Android how to setup

Android has turned out to be the most popular open source operating system forย mobile phones. The OS can be customized, modified or even personalized in numerous different ways. Gaining rootย access has become quite common with Android due to theย variousย privileges that come with it. However, in order to get into Android development, you need to get familiar with ADB and Fastboot commands. So here are the most useful ADB and fastboot commands for you.

ADB, which stands for Android debugging, can be used to issue a set of array commands to your Android device through a terminal or cmd. ADB commands can perform operations like a reboot, sideload OTA updates, install APK files, or even extract system apps.

Fastboot commands can be issued via bootloader or fastboot menu to flash firmware files or custom recoveries. Most common use it toย unlock the bootloader of your Android device. These commands can be issued via command prompt or terminal using a Windows PC, Mac or Linux machine.

Warning: If you are not sure about any command, you should refrain from using it. Some of the changes may not be restored. So be cautious.

Most commonly used ADB commands

  • adb devices โ€“ list all connected devices
  • adb reboot โ€“ perform a reboot
  • adb reboot bootloader โ€“ reboot into bootloader or fastboot menu
  • adb reboot recovery โ€“ reboots into recovery [stock or TWRP whichever is installed]
  • adb reboot download โ€“ reboots the device into download mode (if available, mainly for LG)
  • adb reboot sideloadย โ€“ reboots the device into sideloading menu
  • adb sideload <filename with extension> โ€“ used to sideload or install OTA updates

For instance-

adb sideload ota.zip
  • adb install โ€“ used to install files and applications on Android

For instance- install and apk file

adb install OPFilemanager.apk

While updating and app use the -r switch

adb install -r OPFilemanager.apk
  • adb uninstall โ€“ used to uninstall APK

For instance-

adb uninstall <filename>.apk
  • adb push <local> <remote> โ€“ copy file/dir to device

For instance-

adb push OPFilemanager.apk sdcard/
  • adb logcat โ€“ get the full logcat orย Android ROM
ย adb logcatย > filename.txt
  • adb pull <remote> [<local>] โ€“ copy file/dir from device

For example-

adb pull /system/reserve/OPFilemanager/OPFilemanager.apk

List of allย ADB commands:

adb devices โ€“ list all connected devices
adb push <local> <remote> โ€“ copy file/dir to device
adb pull <remote> [<local>] โ€“ copy file/dir from device
adb sync [ <directory> ] โ€“ copy host->device only if changed
(-l means list but donโ€™t copy)
(see โ€˜adb help allโ€™)
adb shell โ€“ run remote shell interactively
adb shell <command> โ€“ run remote shell command
adb emu <command> โ€“ run emulator console command
adb logcat [ <filter-spec> ] โ€“ View device log
adb forward <local> <remote> โ€“ forward socket connections forward specs are one of: tcp:<port>
localabstract:<unix domain socket name>
localreserved:<unix domain socket name>
localfilesystem:<unix domain socket name>
dev:<character device name>
jdwp:<process pid> (remote only)
adb jdwp โ€“ list PIDs of processes hosting a JDWP transport
adb install [-l] [-r] [-s] <file> โ€“ push this package file to the device and install it
(โ€˜-lโ€™ means forward-lock the app)
(โ€˜-rโ€™ means reinstall the app, keeping its data)
(โ€˜-sโ€™ means install on SD card instead of internal storage)
adb uninstall [-k] <package> โ€“ remove this app package from the device
(โ€˜-kโ€™ means keep the data and cache directories)
adb bugreport โ€“ return all information from the device
that should be included in a bug report.
adb help โ€“ show this help message
adb version โ€“ show version num

DATAOPTS:ย risk factor involved

(no option) โ€“ donโ€™t touch the data partition
-w โ€“ wipe the data partition
-d โ€“ flash the data partition

Scripting:ย risk factor involved

adb wait-for-device โ€“ block until device is online
adb start-server โ€“ ensure that there is a server running
adb kill-server โ€“ kill the server if it is running
adb get-state โ€“ prints: offline | bootloader | device
adb get-serialno โ€“ prints: <serial-number>
adb status-window โ€“ continuously print device status for a specified device
adb remount โ€“ remounts the /system partition on the device read-write
adb reboot [bootloader|recovery] โ€“ reboots the device, optionally into the bootloader or recovery program
adb reboot-bootloader โ€“ reboots the device into the bootloader
adb root โ€“ restarts the adbd daemon with root permissions
adb usb โ€“ restarts the adbd daemon listening on USB
adb tcpip <port> โ€“ restarts the adbd daemon listening on TCP on the specified port

networking: risk factor involved

adb ppp <tty> [parameters] โ€“ Run PPP over USB.
Note: you should not automatically start a PPP connection.
< tty> refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1
[parameters] โ€“ Eg. defaultroute debug dump local notty usepeerdns
adb sync notes: adb sync [ <directory> ]
< localdir> can be interpreted in several ways:
โ€“ If <directory> is not specified, both /system and /data partitions will be updated.
โ€“ If it is โ€œsystemโ€ or โ€œdataโ€, only the corresponding partition is updated.

Most commonly used Fastboot commands

Fastboot commands will only work in bootloader or fastboot menu. Issue the following command to reboot into fastboot or bootloader menu.

adb reboot bootloader

OR

adb reboot fastboot

OR

adb reboot-bootloader
  • fastboot devices โ€“ lists connected Android devices accessible via fastboot
  • fastboot oem device-info โ€“ provides bootloader information (locked or unlocked)

Should not use the following, unless absolutely sure!

  • fastboot erase system โ€“ wipe/eraseย system
  • fastboot erase data โ€“ wipe/erase data
  • fastboot erase cache โ€“ wipe/erase cache
  • fastboot flash
  • fastboot flash recovery <filename>ย  โ€“ย flash recovery image
  • fastboot flash boot <filename>ย  โ€“ย flash boot image
  • fastboot flash system <filename>ย  โ€“ย flash system image
  • fastboot flash data <filename>ย  โ€“ย flash data image
  • fastboot flash cache <filename>ย  โ€“ย flash cache image
  • fastboot flash userdata <filename>ย  โ€“ย flash userdata image
  • fastboot flash bootloader <filename>ย  โ€“ย flash bootloader image
  • fastboot flash radio <filename>ย  โ€“ย flash radio image
  • fastboot help

List of all fastboot commands

Usage: fastboot [ <option> ] <command>

commands:
update <filename> reflash device from update.zip
flashall flash boot + recovery + system
flash <partition> [ <filename> ] write a file to a flash partition
erase <partition> erase a flash partition
getvar <variable> display a bootloader variable
boot <kernel> [ <ramdisk> ] download and boot kernel
flash:raw boot <kernel> [ <ramdisk> ] create bootimage and flash it
devices list all connected devices
reboot reboot device normally
reboot-bootloader reboot device into bootloader
options:
-w erase userdata and cache
-s <serial number> specify device serial number
-p <product> specify product name
-c <cmdline> override kernel commandline
-i <vendor id> specify a custom USB vendor id
-b <base_addr> specify a custom kernel base address
-n <page size> specify the nand page size. default: 2048

How to setup and issue ADB or Fastboot commands via terminal?

The above commands wonโ€™t work for Android unless ADB or Fastboot environment is setupย on the personal computer. We have already listed aย quicker and easier method to setup ADB and Fastboot on Windows, Mac OS, Linux, and Chrome OS.

Prerequisites

1.ย Enable USB Debugging on your device. To do so, go to Settings>About Phone> Tap on the Build Number several times until you get a newย Developer Options in theย Settings.ย Openย Developer Options and enable USB Debugging from there.ย Trust the connection by allowing it when you connect it to your PC for the first time.

2.ย Make sure you have ADB and Fastboot environmentย setup on Windows, Mac OS, Linux or Chrome OS. You may also like Universal ADB drivers, Naked ADB drivers.

3.ย Make sure you have latest device drivers setup on your PC for a better connection. Get it from the official pageย of your device manufacturer.

Instructions to use ADB and Fastboot commands

Step 1:ย Go through the prerequisites. Now,ย connect your Android device to the PC and trust the connection- tap Yes on โ€œAlways allow from this computerโ€ when you plug in the device into PC for the first time.

Step 2:ย Now launch a command prompt or terminal window anywhere. To do so, just click the address bar and type cmd and press Enter key or hold the shift key on the keyboard and right-click on an empty space and select โ€œOpen command window hereโ€ option to launch a cmd window.

Note: If you have installed the quick ADB installer, it will setup the ADB and Fastboot everywhere on your PC. If you use the minimal ADB package, then navigate to the location where you have setup ADB and Fastboot and launch a command prompt or terminal window there.

Step 3: Now hereโ€™s a trick. ADB and Fastboot work in different environments. For ADB commands to work, your devices need to be booted into the system and connected with USB debugging. For Fastboot commands to work, your device must be booted into bootloader or fastboot menu. (You can reboot into bootloader by issuing the following command)

adb reboot bootloader

Step 4: Once in the bootloader, issue the following fastboot command toย check connectivity.

fastboot devices

Like, share, and follow us on social media. For queries, comment down below.


Sarang Avatar

2 responses


  1. babar bashir Avatar
    babar bashir

    Adb uninstall OR
    Adb shell
    $ pm uninstall

  2. GuccizBud Avatar
    GuccizBud

    Just fyi, “ADB” is an acronym for “Android Debug Bridge” โ€Š(โ€Šnot “Android debugging”). I still love you thoughโ€‰??.

Leave a Reply