0% found this document useful (0 votes)
127 views14 pages

List of All Widely Used ADB Commands - Tech Blogs

Uploaded by

Andy Michel Cuba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
127 views14 pages

List of All Widely Used ADB Commands - Tech Blogs

Uploaded by

Andy Michel Cuba
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.

com/list-of-all-widely-used-adb-commands/

Android Technology Security Testing More   Search

List Of All Widely Used ADB Commands


Amit Savaliya in Android , Programming
January 19, 2022 19 mins read

(adb) commands are very useful while debugging any Android device but at
the same time it’s dif�cult to �nd all the commands at one place.

In this article, you will �nd 200+ ADB, shell and fastboot commands which are commonly used for
debugging Android devices. Using these commands can reduce the required efforts and can help
achieve the required result in less time.

Below is the list of commands which can be executed from command prompt or terminal on Android
devices while the device is connected with the computer with USB debugging turned on.

If anyone has used ADB in the past then they must have used ‘adb devices’ to list all the connected
devices. However, it’s not just limited to listing the devices, we can connect devices using wires or
wirelessly and even control the ADB server. Here are the few commands which can help to connect
and list the devices.

To List all connected devices via adb adb devices

To List connected devices (-l for long output) adb devices -l

To list all devices connected via USB or To restart adb device in USB adb usb
mode

To list all forward socket connections adb forward –list

To set up port forwarding (sets up forwarding of computer port 6123 adb forward tcp�6123
to Android device port 7123) tcp�7123

To start the ADB server process adb start-server

To terminates the adb server process adb kill-server

To Set the target device to listen for a TCP/IP connection on port adb tcpip 5555adb
5555Connect a device using Wi-Fi network.Con�rm that your host connect 192.xxx.xxx.xxadb
computer is also connected to the Android device over Wi-Fi devices
Help Text: disconnect the USB cable from the Android device�nd
your Android device IP address at Settings > About phone > Status >
IP addressList of devices attached192.xxx.xxx.xx�5555 device

The basic operations which everyone perform using ADB commands are to install and uninstall
applications. ADB commands are also used to get the information of the applications installed on the

1 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

device. Below are some ADB and shell commands to manage and get information about applications
on the device.

To push a single application to the device and adb install <apk_name.apk>


install.

To push multiple applications to the device and adb install-multiple <apkname.apk>


install. <apkname2.apk>

To push multiple applications to the device and adb install-multi-package <apkname.apk>


install it automatically. <apkname2.apk>

To replace existing application by keeping its adb install -r <apkname.apk>


data.

To install apk in external storage adb install -s <apkname.apk>

To allow test packages adb install -t <apkname.apk>

To uninstall apk by package name adb uninstall <package_name_of_apk>

To uninstall apk by package name while keeping adb uninstall -k <package_name_of_apk>


cache and app data

To clear application data by package name adb shell pm clear <package_name_of_apk>

To uninstall system application by package name adb shell pm uninstall -k –user 0


<package_name_of_apk>

To disable application by package name adb shell pm disable <package_name_of_apk>

To disable application by package name for adb shell pm disable-user –user 0


system user <package_name_of_apk>

To disable re-enable disabled application by adb shell pm enable <package_name_of_apk>


package name

To hide application by package name adb shell pm hide <package_name_of_apk>

To unhide application by package name adb shell pm unhide <package_name_of_apk>

To suspend any application by package name adb shell pm suspend


<package_name_of_apk>

To re-enable suspended application by package adb shell pm unsuspend


name <package_name_of_apk>

To list package name of all installed apks adb shell pm list packages

To list package name of all system apps adb shell pm list packages -s

To list package name of third party adb shell pm list packages -3


apps installed on the device

To list package name of disabled apps on the adb shell pm list packages -d
device

2 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To list package name of only enabled apps on the adb shell pm list packages -e
device

To list package name of uninstalled apps from adb shell pm list packages -u
the device

While debugging an android device, rebooting the device or rebooting in the recovery mode or
bootloader mode is required for operations like sideloading any image or application. Below are some
commands to achieve the same.

To reboot the device adb reboot

To reboot device in bootloader or fastboot mode adb reboot bootloader

To reboot device in recovery mode adb reboot recovery

To restart ADB device with root permission adb root

To restart ADB device without root permission adb unroot

To manually install OTA package using recovery mode adb sideload ota-update�le.zip

Logs and Bug Reports contain useful information related to application and are important for
developers while �xing bugs or making changes in the application. Here are some commands which
are useful for taking bug reports and collecting logs.

To display full logcat data on the computer screen adb logcat

To clear current logcat data adb logcat -c

To save current logcat data in local �le adb logcat -d <path>

To generate bug report of connected device adb bugreport <path>

To get the serial number of connected device adb get-serialno

To wait for android device until the current process is completed adb wait-for-device

To get the device state in the terminal/command prompt adb get-state

To list JDWP (Java Debug Wire Protocol) processes of android device adb jdwp

It’s always a good idea to take a backup of your device’s data so that it can be restored later whenever

3 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

it’s required but if you are unlocking the bootloader or debugging the device then it’s highly
recommended to take backup. Here are some commands which can help you with the same.

To take full backup of android device to computer adb backup //

To restore backup from computer to device adb restore //

To take backup of apps and settings adb backup -apk -all -f backup.ab

To take backup of applications and application settings adb backup -apk -shared -all -f
and shared storage backup.ab

To take backup of only third party applications. adb backup -apk -nosystem -all -f
backup.ab

To connect to device using its ip address adb connect ip_address_of_device

To restore previously created backup adb restore backup.ab

Performing copy-paste using explorer requires a lot of time and also compared to ADB it’s a little
slow. You must have used ADB push and ADB pull for �le operations but here are some more
commands which can help you more with �le operations.

To copy or transfer a �le from a device’s adb pull /system/app/<apkname.apk>


storage to a computer.

To transmit or push a �le from a adb push /local/path/<apkname.apk> /sdcard/apps/


computer to a device

To copy �les inside device storage from adb shell<enter>cp /sdcard/<�lename.extension> /


one folder to another folder. sdcard/foldername

To move �les inside device storage from adb shell<enter>mv /sdcard/<�lename.extension> /


one folder to another folder. sdcard/foldername

To move �le inside the device storage adb shell<enter>mv /sdcard/<�lename.extension> /


and rename the �le in destination folder sdcard/apps/<new�lename.extension>

Information like screen resolution, pixel density and refresh rate are usually not getting displayed in
the device and to get such information the user has to struggle a lot in Android settings and it’s even
dif�cult to change it. Below are some commands to get the same information and change it using
shell.

4 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To start remote shell console adb shell

To get pixel density, screen resolution, refresh rate and DPI information of adb shell wm density
android device

To change screen resolution of android deviceNote: enter values based on adb shell wm size
the supported resolution of device 1080×2220

To change pixel density of android deviceNote: enter values based on the adb shell wm density
supported density of device 480

Using ADB, users can only perform 1 operation at a time on device storage but shell gives an
advantage here to move inside any directory and then perform any operations on the same folder.
Here are some important directories which are really useful.

To start remote shell console adb shell

To change directory to /system adb shell<enter>cd /system

To delete �le from device adb shell<enter>rm -f /sdcard/


<apkname.apk>

To delete folder from device adb shell<enter>rm -d /sdcard/test

To create folder in device adb shell<enter>mkdir /sdcard/test

To check network statistic of android device adb shell<enter>netstat

To get IP address information of device’s WIFI adb shell<enter>ip -f inet addr show
wlan0

To get the list and monitor all process running on adb shell<enter>top
android device

To get the properties of android build.prop adb shell<enter>getprop


con�guration ro.build.version.sdk

To Set/replace the properties of android build.prop adb shell<enter>setprop net.dns1 4.4.4.0


con�guration

Using shell commands users can get the information related to software and hardware for battery,
display and battery stat which are useful for building an application. Below are the commands to get
them.

5 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To get display information of device relating to software and hardware adb shell dumpsys display
con�guration

To get battery information of device relating to software and adb shell dumpsys
hardware con�guration battery

To get battery stats information of device relating to software and adb shell dumpsys
hardware con�guration batterystats

Screen Record functionality is not available with old android devices but shell scripts are there to
overcome that limitation. Also, some users don’t want to even touch the devices while the device is
connected for debugging. So, the user needs commands to perform all those operations from the
computer. Here are a few commands to perform those operations remotely from the computer.

To send SMS from android device using adb shell am start -a android.intent.action.SENDTO
ADB -d sms:<phonenumber> –es sms_body “<SMS
Text>” –ez exit_on_sent true

adb shell input keyevent 22adb shell input keyevent


66

To take screenshot using ADB command adb shell screencap /sdcard/screenshot.png

To start screen recording using ADB adb shell screenrecord /sdcard/movie.mp4


command
Note: To stop the screen recording press
CTRL+C or COMMAND+C

To start screen recording by de�ning adb shell screenrecord –size 1440 x 2960 /sdcard/
output resolution using ADB command. movie.mp4
Note�1. To stop the screen recording press
CTRL+C or COMMAND+C2. Enter
resolution values based on the supported
resolution of the device.

To start screen recording using ADB adb shell screenrecord –time-limit 36 /sdcard/
command and set recording duration. movie.mp4
Note: Replace ‘36’ with desired value in
seconds.

To start screen recording using ADB adb shell screenrecord –bit-rate 1500000 /sdcard/
command and set the bitrate of the video movie.mp4
output �le.

Most Android developers and testers want to automate actions on Android devices but it needs a

6 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

separate setup to achieve it. While ADB provides some inbuilt commands to perform those actions.
Below are the key event commands of shell to perform action remotely from computer:

To press HOME button using ADB adb shell input keyevent 3oradb shell am start -W -c
android.intent.category.HOME -a
android.intent.action.MAIN

To press BACK button using ADB adb shell input keyevent 4

To press CALL button using ADB adb shell input keyevent 5

To press END CALL button using ADB adb shell input keyevent 6

To to toggle device to ON/OFF adb shell input keyevent 26

To launch camera using ADB adb shell input keyevent 27

To launch default browser using ADB adb shell input keyevent 64

To press enter using ADB adb shell input keyevent 66

To press delete or backspace using ADB adb shell input keyevent 67

To launch contacts list using ADB adb shell input keyevent 207

To turn down brightness level using adb shell input keyevent 220
ADB

To turn up brightness level using ADB adb shell input keyevent 221

To perform Cut (ctrl+x) operation on adb shell input keyevent 277


selected item using ADB command

To perform Copy (ctrl+c) operation on adb shell input keyevent 278


selected item using ADB command

To perform Paste operation (ctrl+v) on adb shell input keyevent 279


selected item using ADB command

To pass keycode(keyboard value) adb shell input keyevent 0


unknown/0 using ADB

To pass keycode(keyboard value) adb shell input keyevent 1


MENU/SOFT_LEFT using ADB

To pass keycode(keyboard value) adb shell input keyevent 2


SOFT_RIGHT using ADB

To pass keycode(keyboard value) HOME adb shell input keyevent 3


using ADB

To pass keycode(keyboard value) BACK adb shell input keyevent 4


using ADB

To pass keycode(keyboard value) CALL adb shell input keyevent 5


using ADB

7 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To pass keycode(keyboard value) END adb shell input keyevent 6


CALL using ADB

To pass keycode(keyboard value) 0 adb shell input keyevent 7


using ADB

To pass keycode(keyboard value) 1 using adb shell input keyevent 8


ADB

To pass keycode(keyboard value) 2 using adb shell input keyevent 9


ADB

To pass keycode(keyboard value) 3 adb shell input keyevent 10


using ADB

To pass keycode(keyboard value) 4 using adb shell input keyevent 11


ADB

To pass keycode(keyboard value) 5 using adb shell input keyevent 12


ADB

To pass keycode(keyboard value) 6 adb shell input keyevent 13


using ADB

To pass keycode(keyboard value) 7 using adb shell input keyevent 14


ADB

To pass keycode(keyboard value) 8 adb shell input keyevent 15


using ADB

To pass keycode(keyboard value) 9 adb shell input keyevent 16


using ADB

To pass keycode(keyboard value) STAR adb shell input keyevent 17


using ADB

To pass keycode(keyboard value) adb shell input keyevent 18


POUND using ADB

To pass keycode(keyboard value) adb shell input keyevent 19


DPAD_UP using ADB

To pass keycode(keyboard value) adb shell input keyevent 20


DPAD_DOWN using ADB

To pass keycode(keyboard value) adb shell input keyevent 21


DPAD_LEFT using ADB

To pass keycode(keyboard value) adb shell input keyevent 22


DPAD_RIGHT using ADB

To pass keycode(keyboard value) adb shell input keyevent 23


DPAD_CENTER using ADB

To pass keycode(keyboard value) adb shell input keyevent 24


VOLUME_UP using ADB

8 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To pass keycode(keyboard value) adb shell input keyevent 25


VOLUME_DOWN using ADB

To pass keycode(keyboard value) adb shell input keyevent 26


POWER using ADB

To pass keycode(keyboard value) adb shell input keyevent 27


CAMERA using ADB

To pass keycode(keyboard value) CLEAR adb shell input keyevent 28


using ADB

To pass keycode(keyboard value) A adb shell input keyevent 29


using ADB

To pass keycode(keyboard value) B adb shell input keyevent 30


using ADB

To pass keycode(keyboard value) C adb shell input keyevent 31


using ADB

To pass keycode(keyboard value) D adb shell input keyevent 32


using ADB

To pass keycode(keyboard value) E adb shell input keyevent 33


using ADB

To pass keycode(keyboard value) F using adb shell input keyevent 34


ADB

To pass keycode(keyboard value) G adb shell input keyevent 35


using ADB

To pass keycode(keyboard value) H adb shell input keyevent 36


using ADB

To pass keycode(keyboard value) I using adb shell input keyevent 37


ADB

To pass keycode(keyboard value) J using adb shell input keyevent 38


ADB

To pass keycode(keyboard value) K adb shell input keyevent 39


using ADB

To pass keycode(keyboard value) L adb shell input keyevent 40


using ADB

To pass keycode(keyboard value) M adb shell input keyevent 41


using ADB

To pass keycode(keyboard value) N adb shell input keyevent 42


using ADB

To pass keycode(keyboard value) O adb shell input keyevent 43


using ADB

9 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To pass keycode(keyboard value) P adb shell input keyevent 44


using ADB

To pass keycode(keyboard value) Q adb shell input keyevent 45


using ADB

To pass keycode(keyboard value) R adb shell input keyevent 46


using ADB

To pass keycode(keyboard value) S adb shell input keyevent 47


using ADB

To pass keycode(keyboard value) T adb shell input keyevent 48


using ADB

To pass keycode(keyboard value) U adb shell input keyevent 49


using ADB

To pass keycode(keyboard value) V adb shell input keyevent 50


using ADB

To pass keycode(keyboard value) W adb shell input keyevent 51


using ADB

To pass keycode(keyboard value) X adb shell input keyevent 52


using ADB

To pass keycode(keyboard value) Y adb shell input keyevent 53


using ADB

To pass keycode(keyboard value) Z adb shell input keyevent 54


using ADB

To pass keycode(keyboard value) adb shell input keyevent 55


COMMA using ADB

To pass keycode(keyboard value) adb shell input keyevent 56


PERIOD using ADB

To pass keycode(keyboard value) adb shell input keyevent 57


ALT_LEFT using ADB

To pass keycode(keyboard value) adb shell input keyevent 58


ALT_RIGHT using ADB

To pass keycode(keyboard value) adb shell input keyevent 59


SHIFT_LEFT using ADB

To pass keycode(keyboard value) adb shell input keyevent 60


SHIFT_RIGHT using ADB

To pass keycode(keyboard value) TAB adb shell input keyevent 61


using ADB

To pass keycode(keyboard value) SPACE adb shell input keyevent 62


using ADB

10 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To pass keycode(keyboard value) SYM adb shell input keyevent 63


using ADB

To pass keycode(keyboard value) adb shell input keyevent 64


EXPLORER using ADB

To pass keycode(keyboard value) adb shell input keyevent 65


ENVELOPE using ADB

To pass keycode(keyboard value) ENTER adb shell input keyevent 66


using ADB

To pass keycode(keyboard value) DEL adb shell input keyevent 67


using ADB

To pass keycode(keyboard value) GRAVE adb shell input keyevent 68


using ADB

To pass keycode(keyboard value) adb shell input keyevent 69


MINUS using ADB

To pass keycode(keyboard value) adb shell input keyevent 70


EQUALS using ADB

To pass keycode(keyboard value) adb shell input keyevent 71


LEFT_BRACKET using ADB

To pass keycode(keyboard value) adb shell input keyevent 72


RIGHT_BRACKET using ADB

To pass keycode(keyboard value) adb shell input keyevent 73


BACKSLASH using ADB

To pass keycode(keyboard value) adb shell input keyevent 74


SEMICOLON using ADB

To pass keycode(keyboard value) adb shell input keyevent 75


APOSTROPHE using ADB

To pass keycode(keyboard value) SLASH adb shell input keyevent 76


using ADB

To pass keycode(keyboard value) AT adb shell input keyevent 77


using ADB

To pass keycode(keyboard value) NUM adb shell input keyevent 78


using ADB

To pass keycode(keyboard value) adb shell input keyevent 79


HEADSETHOOK using ADB

To pass keycode(keyboard value) adb shell input keyevent 80


FOCUS using ADB

To pass keycode(keyboard value) PLUS adb shell input keyevent 81


using ADB

11 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To pass keycode(keyboard value) MENU adb shell input keyevent 82


using ADB

To pass keycode(keyboard value) adb shell input keyevent 83


NOTIFICATION using ADB

To pass keycode(keyboard value) adb shell input keyevent 84


SEARCH using ADB

To pass keycode(keyboard value) adb shell input keyevent 85


MEDIA_PLAY/PAUSE using ADB

To pass keycode(keyboard value) adb shell input keyevent 86


MEDIA_STOP using ADB

To pass keycode(keyboard value) NEXT adb shell input keyevent 87


using ADB

To pass keycode(keyboard value) adb shell input keyevent 88


PREVIOUS using ADB

To pass keycode(keyboard value) adb shell input keyevent 89


MEDIA_REWIND using ADB

To pass keycode(keyboard value) adb shell input keyevent 90


MEDIA_FAST_FORWARD using ADB

To pass keycode(keyboard value) MUTE adb shell input keyevent 91


using ADB

To pass keycode(keyboard value) PAGE adb shell input keyevent 92


UP using ADB

To pass keycode(keyboard value) PAGE adb shell input keyevent 93


DOWN using ADB

To pass keycode(keyboard value) PICT adb shell input keyevent 94


SYMBOLS using ADB

To pass keycode(keyboard value) adb shell input keyevent 122


MOVE_HOME using ADB

To pass keycode(keyboard value) adb shell input keyevent 123


MOVE_END using ADB

Fastboot enables options for users to �ash custom image and recovery �les using fastboot mode.
Some useful operations and it’s commands are listed below:

To list all fastboot devices fastboot devices

To unlock bootloader of connected fastboot device fastboot oem unlock

12 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To re-lock bootloader of connected fastboot device fastboot oem lock

To reboot device in fastboot or bootloader mode from fastboot fastboot reboot bootloader
mode

To �ash boot image using fastboot mode fastboot �ash boot boot.img

To �ash recovery image using fastboot mode fastboot �ash recovery


recovery.im

To boot custom Image in device without �ashing the image �le fastboot boot �lename.img

Device information such as IMEI, Serial Number and also �les available in device storage are
important for us but at the same time it’s not easy to �nd some of this information as it’s hidden for
users like system storage where �rmware �les are available. Some of this information are required
while debugging the device. Some commands to get this information are given below:

To list directory content adb shell ls

To print size of each �le in selected directory adb shell ls -s

To print list of subdirectories recursively adb shell ls -R

To print state of device adb get-statе

To print IMEI of connected device adb shell dumpsys iphonesybinfo

To print information related to connectivity like TCP Ip and adb shell netstat
connections

To print information of current working directory adb shell pwd

To print list of phone features adb shell pm list features

To print list of all services of device adb shell service list

To print information of application activity by package and adb shell dumpsys activity
activity name <package>/<activity>

To print process status adb shell ps

To print current display resolution information adb shell wm size

To print activity of current opened application dumpsys window windows | grep -


E ‘mCurrentFocus|mFocusedApp’

To list the information of all opened apps adb shell dumpsys package
packages

To get the information of particular application adb shell dump <name>

To get the path of application by package name adb shell path <package>

13 of 14 4/25/2024, 4:01 PM
List of all widely used ADB commands - Tech Blogs https://techblogs.42gears.com/list-of-all-widely-used-adb-commands/

To change battery level of device (emulator)Note: Value can adb shell dumpsys battery set
be 0 to 100 level <n>

To change battery status of device (emulator)Note: Value can adb shell dumpsys battery set
be 0 to 3 which relates to state unknown, charging, status<n>
discharging, not charging or full

To reset battery status of device (emulator) adb shell dumpsys battery reset

To change USB status of device (emulator)Note: Value can be adb shell dumpsys battery set usb
0 or 1 <n>

ADB is very useful. However, not being aware of some of these commands prevents users from
utilising this powerful tool. I hope these commands will help you while using ADB. There are still
some more commands which are not included here because of their limited and complicated use.. In
case you wish to learn more about all supported commands on your device then ‘adb –help’ can help.

Share this post   

Sandeep Kadam in Android , Editor's Pick Ankur Agrawal in Android


December 20, 2022 7 mins read November 28, 2022 2 mins read

Show All Responses

©2024 42Gears Mobility Systems Pvt Ltd. All Rights Reserved. Terms Of Use (Website) Privacy Notice

14 of 14 4/25/2024, 4:01 PM

You might also like