ADB and Fastboot are essential tools for Android developers and advanced users. This article provides a complete list of the most useful ADB and Fastboot commands, acting as a handy reference for troubleshooting Android devices, sideloading apps, managing backups, and more. Whether you’re flashing custom ROMs or need to reboot into recovery, this guide has the ADB and Fastboot commands you need.
What is ADB and How it works?
ADB stands for Android Debug Bridge, a software developed by Google for Android developers to test their software and Applications for the Android OS.
ADB allows communication between a computer and an Android device for debugging purposes. It consists of three components – a client, daemon, and server.
Also Read: How to Use ADB without PC – LADB
The adb daemon runs on the Android device as adbd. The adb client runs on the computer and communicates with adbd to send commands and transfer data. The adb server manages communication between the client and the daemon.
ADB uses TCP port 5037 for communication. This allows actions like installing apps, accessing phone data, managing processes, and debugging apps on Android devices.
List of ADB Commands and their Operations
Below is the list of ADB commands that can be used to perform certain operations when the Android device is connected to the computer and the USB debugging is Enabled. You can check our guide on how to unlock USB debugging on HyperOS. If your Xiaomi phone has HyperOS installed on it.
adb devices
The adb devices
command identifies connected Android devices with USB Debugging enabled, displaying their serial numbers and states.
Syntax:
adb devices
Response:
a123a456 device
adb forward
The adb forward
command establishes the forward socket connections. It also requires USB Debugging enabled on your Android device.
Syntax:
adb forward <local> <remote>
Example:
adb forward tcp:6100 tcp:7100
Set up forwarding of the host port 6100
to emulator/device port 7100
adb kill-server
The adb kill-server
command shuts down the adb
server, which is useful for troubleshooting issues.
Syntax:
adb kill-server
adb connect
The adb connect
allows you to connect for wireless ADB, but both devices need to be on the same Wi-Fi.
Syntax:
adb connect <host>[:<port>]
To use ADB over Wi-Fi, you must first connect your Android device to a PC and set the TCP IP port to 5555
using the “adb tcpip 5555
” command. Now, find the device’s IP address from Settings > About > Status > IP Address.
Now you are ready to use the adb connect command.
Example:
adb connect 192.168.x.x:5555
adb usb
The adb usb
command restarts your ADB into USB Mode.
Syntax:
adb usb
adb install
The adb install
command lets you install an Android Application (.apk) directly from your computer to your Android device.
Syntax:
adb install [option] <path to .apk>
Example:
adb install test.apk
adb uninstall
The adb uninstall
command lets you uninstall an Android Application (.apk) from the emulator or Android device.
Syntax:
adb uninstall [option] <PACKAGE>
Example:
adb uninstall com.test.app
adb shell pm list packages
The adb shell pm list packages
command prints all packages installed on the Android device or emulator.
Syntax:
adb shell pm list packages [options] <FILTER>
Example:
adb shell pm list packages
adb shell pm path
The adb shell pm path
command is used to print the path of a specific Android application package (.apk) on your device.
Syntax:
adb shell pm path <PACKAGE>
Example:
adb shell pm path com.android.phone
adb shell pm clear
The adb shell pm clear
command deletes all the data associated with the package (clears app data and cache).
Syntax:
adb shell pm clear <PACKAGE>
Example:
adb shell pm clear com.test.app
adb pull
The adb pull
command downloads or pulls a specific file from your Android device to your computer.
Syntax:
adb pull <remote> [local]
Example:
adb pull /sdcard/test.mp4
To download test.mp4 to drive D, the below command is used.
adb pull /sdcard/test.mp4 d:\
adb push
The adb push
command is used to upload, push, or copy a file from the computer to an Android device.
Syntax:
adb push <local> <remote>
Example:
adb push d:\test.mp4 /sdcard
adb shell ls
The adb shell ls
command lists directory contents.
Syntax:
ls [options] <directory>
Example:
adb shell
ls
adb shell cd
The adb shell cd
command Changes the directory or folder.
Syntax:
cd <directory>
Example:
adb shell
cd /system
adb shell rm
The adb shell rm
command is used to remove files or directories.
Syntax:
rm [options] <files or directory>
Example:
adb shell
rm /sdcard/test.pdf
adb shell mkdir
The adb shell mkdir
command makes a directory or creates a folder.
Syntax:
mkdir [options] <directory name>
Example:
adb shell
mkdir /sdcard/test
adb shell touch
The adb shell touch
creates an empty file or changes file timestamps.
Syntax:
touch [options] <file>
Example:
adb shell
touch /sdcard/test.txt
adb shell pwd
The adb shell pwd
prints the current working directory location.
Syntax:
pwd
Example:
adb shell
pwd
adb shell cp
The adb shell cp
command copies files and directories.
Syntax:
cp [options] <source> <destination>
Example:
adb shell
cp /sdcard/text.txt /sdcard/folder/
adb shell mv
The adb shell mv
command moves or renames files.
Syntax:
mv [options] <source> <destination>
Example:
adb shell
mv /sdcard/tmp /system/tmp
adb shell netstat
The adb shell netstat
command shows network statistics.
Syntax:
netstat
Example:
adb shell
netstat
adb shell ping
The adb shell ping
command tests the connection and the latency between two network connections.
Syntax:
ping [options] <destination>
Example:
adb shell
ping www.android.com
adb shell netcfg
The adb shell netcfg
command manages and configures network connections via profiles.
Syntax:
netcfg [<interface> {dhcp|up|down}]
Example:
adb shell
netcfg
adb shell ip
The adb shell ip
command shows and manipulates routing, devices, policy routing, and tunnels.
Syntax:
ip [options] object
object
:= { link | addr | addrlabel | route | rule | neigh | ntable |tunnel | tuntap | maddr | mroute | mrule | monitor | xfrm |netns | l2tp }
options
:= { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |-f[amily] { inet | inet6 | ipx | dnet | link } |-l[oops] { maximum-addr-flush-attempts } |-o[neline] | -t[imestamp] | -b[atch] [filename] |-rc[vbuf] [size]}
Example:
adb shell
ip -f inet addr show wlan0
adb logcat
The adb logcat
command prints log data on the screen.
Syntax:
adb logcat
adb shell dumpsys
The adb shell dumpsys
command dumps system data.
Syntax:
adb shell dumpsys [options]
Example:
adb shell dumpsys
adb shell dumpsys batterystats
adb shell dumpstate
The adb shell dumpstate
command dumps state.
Syntax:
adb shell dumpstate
adb shell screencap
The adb shell screencap
command takes a screenshot of the Android device’s display.
Syntax:
adb shell screencap <filename>
Example:
adb shell screencap /sdcard/screenshot.png
adb shell screenrecord
The adb shell screenrecord
command records the Android device’s screen. For this code to work, your Android device should be running on Android 4.4 (API level 19) or higher.
Syntax:
adb shell screenrecord [options] <filename>
Example:
adb shell screenrecord /sdcard/screen.mp4
adb root
The adb root command
is used to restart the adbd(daemon)
with root permissions.
Syntax:
adb root
adb sideload
The adb sideload
command sideloads the OTA update.zip package and other files on the Android device.
Syntax:
adb sideload <file.zip>
Example:
adb sideload update.zip
adb shell ps
The adb shell ps
command prints the process status.
Syntax:
ps [options]
Example:
adb shell
ps
adb shell top
The adb shell top
command displays the top CPU processes.
Syntax:
top [options]
Example:
adb shell
top
adb shell getprop
The adb shell getprop
command lets you check the Android property service.
Syntax:
getprop [options]
Example:
adb shell
getprop
adb shell setprop
The adb shell setprop
command is used to set property service.
Syntax:
setprop <key> <value>
Example:
adb shell
setprop service.adb.tcp.port 5555
What is Fastboot and How it works?
Fastboot is a protocol used for communicating with bootloaders on Android devices. It allows flashing system images, boot images, and other firmware files to an Android device from a connected computer.
It works through a client-server model. The fastboot client is a command line utility installed on the computer. The fastboot server runs on the Android device as part of the bootloader. And if you are running on HyperOS and don’t know how to unlock the bootloader, follow our guide on How to Bypass Xiaomi HyperOS Bootloader.
Fastboot uses USB for communication and allows low-level access to the Android operating system, making it useful for development, hacking, and modding. It complements ADB for device management.
List of Fastboot Commands and their Functions
Below is the list of fastboot commands that can be used to perform certain functions when the Android device is connected to the computer in Fastboot mode or Bootloader mode.
fastboot devices
The fastboot devices
command identifies connected Android devices in fastboot mode.
Syntax:
fastboot devices
fastboot reboot
The fastboot reboot
command reboots the Android device to normal or standard mode. This command is used to exit the fastboot mode or bootloader mode.
Syntax:
fastboot reboot
fastboot reboot recovery
The fastboot reboot recovery
command boots the Android device into Recovery Mode.
Syntax:
fastboot reboot recovery
fastboot oem unlock
The fastboot oem unlock
command unlocks the bootloader on the Android device.
Syntax:
fastboot oem unlock
fastboot oem lock
The fastboot oem lock
command locks the bootloader on the Android device.
Syntax:
fastboot oem lock
fastboot oem device-info
The fastboot oem device-info
prints the bootloader lock or unlock status.
Syntax:
fastboot oem device-info
fastboot flash recovery
The fastboot flash recovery
command is used to flash the recovery image to the Android device.
Syntax:
fastboot flash recovery <file-name.img>
Example:
fastboot flash recovery twrp.img
fastboot boot
The fastboot boot
command is used to boot the image file without installing or flashing on the Android device. It can be used to boot recovery images without flashing on the Android device.
Syntax:
fastboot boot <file-name.img>
Example:
fastboot boot recovery.img
fastboot flash
The fastboot flash
command flashes a flashable zip file from fastboot or bootloader mode.
Syntax:
fastboot flash <file.zip>
Example:
fastboot flash update.zip
fastboot getvar cid
The fastboot getvar cid
command displays the CID (Carrier ID) of the Android device.
Syntax:
fastboot getvar cid
FAQs
What is ADB?
ADB (Android Debug Bridge) is a command line tool that lets you communicate with an Android device. It can be used to install/uninstall apps, copy files to/from the device, grant permissions, view logs, etc.
What is Fastboot?
Fastboot is a tool primarily used to flash system images to Android devices over USB. It can flash partition images, bootloaders, Kernels, etc. It is generally used for more advanced tasks like installing custom ROMs or rooting.
How do I install ADB and Fastboot?
To install ADB and Fastboot on Windows, you need the Android SDK Platform Tools package. Download and extract it, and add the platform-tools folder to your PATH. For Linux/macOS, install them using the package manager.
What are some common ADB commands?
Some common ADB commands are:
- adb devices – List connected devices
- adb install app.apk – Install an APK
- adb uninstall com.package.name – Uninstall an app
- adb logcat – View device logs
- adb reboot – Reboot the device
- adb shell – Get a remote shell on device
What are some common Fastboot commands?
Some common Fastboot commands are:
- fastboot devices – List connected devices
- fastboot flash recovery recovery.img – Flash recovery
- fastboot boot kernel.img – Boot a boot.img
- fastboot erase boot – Erase boot partition
- fastboot oem unlock – Unlock bootloader
- fastboot reboot – Reboot device
How do I get into Fastboot mode on Android?
To get into Fastboot mode, turn off your device and then hold Volume Down + Power. This will boot into the Fastboot mode, from where you can execute Fastboot commands.
What’s the difference between ADB and Fastboot?
ADB is used while the device is booted into Android. In contrast, Fastboot is primarily used in bootloader mode before the Android OS loads. ADB is better for app/file operations, while Fastboot deals with flashing firmware and kernels.
Conclusion
ADB and Fastboot are essential for unlocking the full potential of Android. Whether you need to install APKs remotely, copy files to a device, access the shell, or flash system images, ADB and Fastboot have you covered.
This guide summarizes the most basic commands for ADB and Fastboot tools, acting as a quick reference for Android developers, enthusiasts, and power users.
With ADB and Fastboot, you have precise control over Android devices needed for tasks like rooting, ROM customization, debugging apps, and more. Mastering these versatile command-line utilities will enhance your ability to manage Android effectively.
I hope this article was helpful, and I’m sure you’ve learned a lot of new things today. In the comment section below, let us know which ADB or Fastboot command you liked the most and why. And if you are facing any issues in this regard, please let us know in the comment section, and we will try our best to help you out.
Also Read: How to Use ADB without PC – LADB
If you like our article, please let us know in the comment section.
LEAVE A REPLY