Table of Contents
ADB (Android Debugging Bridge) plays the most important role in modifying your Android Device.
In simple words, Android Debug Bridge (ADB) is a versatile command-line tool that lets you communicate with a device.
ADB allows you to
- Install, copy, and delete files;
- Install a program on a device;
- Record a video or take a screenshot of the phone;
- Debug a device in case of its malfunction;
- Examine logs on the phone;
- Upgrade the firmware of the programs and system elements;
- Get full access to information about OS and a device.
Install ADB on Windows
- To install visit ADB Platform Tools for Windows.
Android Platform Tools
Android Platform Tools is a package containing command-line utilities necessary for communicating with Android devices from a computer. These tools include ADB (Android Debug Bridge), Fastboot, and other debugging and diagnostic utilities. Developers use Platform Tools for tasks such as installing apps, debugging, transferring files, and more.
- Download and Extract the file.
- Move/Copy the directory to C:\ drive and Rename it to "adb".
- Set up Environment Variable.
To do this Go to This PC and right-click. Click on properties.
Install ADB on Linux
1) Installing ADB on Linux is quite simple. For Debian based operating system, use the following command:
Or, if it doesn’t work,
2) Let’s test whether it works or not using the following command:
Run ADB
1) To fully use all the ADB functions on Android devices, it is necessary to make certain changes in the phone settings. Depending on the manufacturer, the configuration menu may vary. But in general, the main actions are the same:Turn on Developer Options
a. Go to settings > About device > Software info. Tap 5 to 7 times on the Build number to turn on the Developer Option.b. Now go back to the Developer Option > Turn on USB debugging.
ADB Basics
Command |
Description |
adb devices |
Lists connected
devices, helping you identify which devices are currently recognized by ADB. |
adb root |
Restarts adbd (the ADB daemon)
with root permissions, enabling access to system-level operations. |
adb
start-server |
Initiates the ADB
server, allowing communication between your computer and Android devices via
ADB commands. |
adb kill-server |
Terminates the ADB server, useful
if you encounter issues or need to reset the ADB server. |
adb reboot |
Reboots the
connected Android device. Useful when changes require a device restart or to
troubleshoot issues. |
adb devices -l |
Provides a detailed list of
connected devices, including their product and model information. |
adb shell |
Opens a
background terminal on the connected Android device, enabling direct
interaction with its command line. |
exit |
Exits the background terminal and
returns you to the local terminal or command prompt on your computer. |
adb help |
Displays a list
of all available ADB commands along with brief descriptions, helping you
discover new commands. |
adb -s
<device> |
Redirects subsequent ADB commands
to a specific device identified by its unique device ID. |
adb –d |
Directs ADB
commands to the only attached USB device, useful when multiple devices are
connected. |
adb –e |
Directs ADB commands to the only
attached emulator, facilitating testing and debugging on virtual devices. |
Package Installation
Command |
Description |
adb shell
install <app> |
Installs the
specified app onto the connected Android device from the local system. |
adb shell
install <path_to_app> |
Installs an app located at the
specified path on the connected Android device. |
adb shell
install -r <path_to_app> |
Reinstalls an app
located at the specified path, replacing the existing version on the
connected Android device. |
adb shell
uninstall <package_name> |
Uninstalls the app identified by
its package name from the connected Android device. |
Paths
Command |
Description |
/data/data/<package_name>/databases |
Represents the
directory on the Android device where app-specific databases are stored. |
/data/data/<package_name>/shared_prefs/ |
Represents the directory on the
Android device where app-specific shared preferences files are stored. |
/data/app |
Refers to the
directory on the Android device where APKs installed by the user are stored. |
/system/app |
Represents the directory on the
Android device where pre-installed system APK files are stored. |
/mnt/asec |
Refers to the
directory on the Android device where encrypted apps (App2SD) are stored. |
/mnt/emmc |
Represents the internal SD card
directory on the Android device. |
/mnt/sdcard |
Represents the
external or internal SD card directory on the Android device, depending on
the device configuration. |
/mnt/sdcard/external_sd |
Represents the external SD card
directory on the Android device, if present. |
adb shell ls |
Lists the
contents of the current directory on the Android device. |
adb shell ls -s |
Lists the contents of the current
directory along with the size of each file. |
adb shell ls
-R |
Lists the
contents of the current directory recursively, including subdirectories and
their contents. |
File Operations
Command |
Description |
adb push
<local> <remote> |
Copies a file or
directory from the local system to the specified location on the Android
device. |
adb pull
<remote> <local> |
Copies a file or directory from
the specified location on the Android device to the local system. |
run-as cat
<file> |
Accesses and
displays the contents of a file located within the private package files of
an installed app. |
Package Info
Command |
Description |
adb shell list
packages |
Lists the package
names of all installed apps on the Android device. |
adb shell list
packages -r |
Lists the package names of all
installed apps along with the path to their corresponding APK files. |
adb shell list
packages -3 |
Lists the package
names of third-party apps installed on the Android device. |
adb shell list
packages -s |
Lists the package names of only
the system apps installed on the Android device. |
adb shell list
packages -u |
Lists the package
names of all installed apps, including those that have been uninstalled but
not yet removed. |
adb shell
dumpsys package packages |
Provides detailed information
about all installed packages on the Android device. |
adb shell dump |
Provides detailed
information about a specific package identified by its package name. |
adb shell path |
Retrieves the file path to the APK
file of a specific package identified by its package name. |
Device Related Commands
Command |
Description |
adb
reboot-recovery |
Reboots the
connected Android device into recovery mode, enabling various system-level
operations. |
adb reboot
fastboot |
Reboots the connected Android
device into fastboot mode, facilitating bootloader-related operations. |
adb shell
screencap -p "/path/to/screenshot.png" |
Captures a
screenshot of the device's current screen and saves it to the specified file
path on the device. |
adb shell
screenrecord "/path/to/record.mp4" |
Records the screen of the
connected Android device and saves it as a video file at the specified location. |
adb backup
-apk -all -f backup.ab |
Creates a backup
of the device's settings and all installed apps, saving it to the specified
file. |
adb backup -apk
-shared -all -f backup.ab |
Creates a backup of the device's
settings, installed apps, and shared storage, saving it to the specified
file. |
adb backup
-apk -nosystem -all -f backup.ab |
Creates a backup
of only the non-system apps installed on the device, saving it to the
specified file. |
adb restore
backup.ab |
Restores a previous backup of the
device's settings and apps from the specified file. |
adb shell am
start <intent> |
Sends an intent
to the Android system to start a specific activity based on the provided
intent parameters. |
adb shell am
start -a android.intent.action.VIEW -d URL |
Opens the default web browser on
the device and navigates to the specified URL. |
adb shell am
start -t image/* -a android.intent.action.VIEW |
Opens the default
image viewer on the device, allowing the user to view images stored locally. |
Configure Settings Commands
Command |
Description |
adb shell
dumpsys battery set level |
Sets the battery
level of the connected Android device to the specified value (0-100). |
adb shell
dumpsys battery set status |
Sets the battery status of the
connected Android device to the specified value (unknown, charging, etc.). |
adb shell
dumpsys battery reset |
Resets the
battery statistics of the connected Android device, clearing any accumulated
data. |
adb shell
dumpsys battery set usb |
Sets the USB connection status of
the connected Android device to either ON or OFF. |
adb shell wm
size WxH |
Sets the screen
resolution of the connected Android device to the specified width (W) and
height (H) in pixels. |
Logs
Command |
Description |
adb logcat
[options] [filter] [filter] |
Displays logs
from the device, allowing you to monitor system and app activity for
debugging purposes. |
adb bugreport |
Generates a bug report containing
information about the device's current state, useful for debugging issues. |
Permissions
Command |
Description |
adb shell
permissions groups |
Lists all
permission groups defined on the connected Android device, providing insight
into app permissions. |
adb shell list
permissions -g -r |
Lists detailed information about
all permissions defined on the connected Android device, including their
groups. |