List of all widely used ADB commands


Android Debug Bridge (adb) commands are very useful while debugging any Android device but at the same time it’s difficult to find all the commands at one place.

In this article, you will find 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.

ADB commands to connect and list devices:

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.

UseCommand
To List all connected devices via adbadb 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 modeadb usb
To list all forward socket connectionsadb forward –list
To set up port forwarding (sets up forwarding of computer port 6123 to Android device port 7123)adb forward tcp:6123 tcp:7123
To start the ADB server processadb start-server
To terminates the adb server processadb kill-server
To Set the target device to listen for a TCP/IP connection on port 5555Connect a device using Wi-Fi network.Confirm that your host computer is also connected to the Android device over Wi-Fi
Help Text: disconnect the USB cable from the Android devicefind your Android device IP address at Settings > About phone > Status > IP addressList of devices attached192.xxx.xxx.xx:5555 device
adb tcpip 5555adb connect 192.xxx.xxx.xxadb devices

ADB and shell commands to manage applications and get the application details:

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 device. Below are some ADB and shell commands to manage and get information about applications on the device.

UseCommand
To push a single application to the device and install.adb install <apk_name.apk>
To push multiple applications to the device and install.adb install-multiple <apkname.apk> <apkname2.apk>
To push multiple applications to the device and install it automatically.adb install-multi-package <apkname.apk> <apkname2.apk>
To replace existing application by keeping its data.adb install -r <apkname.apk>
To install apk in external storageadb install -s <apkname.apk>
To allow test packagesadb install -t <apkname.apk>
To uninstall apk by package nameadb uninstall <package_name_of_apk>
To uninstall apk by package name while keeping cache and app dataadb uninstall -k <package_name_of_apk>
To clear application data by package nameadb shell pm clear <package_name_of_apk>
To uninstall system application by package nameadb shell pm uninstall -k –user 0 <package_name_of_apk>
To disable application by package nameadb shell pm disable <package_name_of_apk>
To disable application by package name for system useradb shell pm disable-user –user 0 <package_name_of_apk>
To disable re-enable disabled application by package nameadb shell pm enable <package_name_of_apk>
To hide application by package nameadb shell pm hide <package_name_of_apk>
To unhide application by package nameadb shell pm unhide <package_name_of_apk>
To suspend any application by package nameadb shell pm suspend <package_name_of_apk>
To re-enable suspended application by package nameadb shell pm unsuspend <package_name_of_apk>
To list package name of all installed apksadb shell pm list packages
To list package name of all system appsadb shell pm list packages -s
To list package name of third party apps installed on the deviceadb shell pm list packages -3
To list package name of disabled apps on the deviceadb shell pm list packages -d
To list package name of only enabled apps on the deviceadb shell pm list packages -e
To list package name of uninstalled apps from the deviceadb shell pm list packages -u

ADB commands to reboot 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.

UseCommand
To reboot the deviceadb reboot
To reboot device in bootloader or fastboot modeadb reboot bootloader
To reboot device in recovery modeadb reboot recovery
To restart ADB device with root permissionadb root
To restart ADB device without root permissionadb unroot
To manually install OTA package using recovery modeadb sideload ota-updatefile.zip

ADB commands for collecting logs and bug report:

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

UseCommand
To display full logcat data on the computer screenadb logcat
To clear current logcat dataadb logcat -c
To save current logcat data in local fileadb logcat -d <path>
To generate bug report of connected deviceadb bugreport <path>
To get the serial number of connected deviceadb get-serialno
To wait for android device until the current process is completedadb wait-for-device
To get the device state in the terminal/command promptadb get-state
To list JDWP (Java Debug Wire Protocol) processes of android deviceadb jdwp

ADB commands to take backup and restore:

It’s always a good idea to take a backup of your device’s data so that it can be restored later whenever 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.

UseCommand
To take full backup of android device to computeradb backup //
To restore backup from computer to deviceadb restore //
To take backup of apps and settingsadb backup -apk -all -f backup.ab
To take backup of applications and application settings and shared storageadb backup -apk -shared -all -f 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 addressadb connect ip_address_of_device
To restore previously created backupadb restore backup.ab

ADB and shell commands to perform file operations:

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 file operations but here are some more commands which can help you more with file operations.

UseCommand
To copy or transfer a file from a device’s storage to a computer.adb pull /system/app/<apkname.apk>
To transmit or push a file from a computer to a deviceadb push /local/path/<apkname.apk> /sdcard/apps/
To copy files inside device storage from one folder to another folder.adb shell<enter>cp /sdcard/<filename.extension> /sdcard/foldername
To move files inside device storage from one folder to another folder.adb shell<enter>mv /sdcard/<filename.extension> /sdcard/foldername
To move file inside the device storage and rename the file in destination folderadb shell<enter>mv /sdcard/<filename.extension> /sdcard/apps/<newfilename.extension>

Shell commands to get and change display resolution:

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 difficult to change it. Below are some commands to get the same information and change it using shell.

UseCommand
To start remote shell consoleadb shell
To get pixel density, screen resolution, refresh rate and DPI information of android deviceadb shell wm density
To change screen resolution of android deviceNote: enter values based on the supported resolution of deviceadb shell wm size 1080×2220
To change pixel density of android deviceNote: enter values based on the supported density of deviceadb shell wm density 480

Shell commands to change directory to some important file location:

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.

UseCommand
To start remote shell consoleadb shell
To change directory to /systemadb shell<enter>cd /system
To delete file from deviceadb shell<enter>rm -f /sdcard/<apkname.apk>
To delete folder from deviceadb shell<enter>rm -d /sdcard/test
To create folder in deviceadb shell<enter>mkdir /sdcard/test
To check network statistic of android deviceadb shell<enter>netstat
To get IP address information of device’s WIFIadb shell<enter>ip -f inet addr show wlan0
To get the list and monitor all process running on android deviceadb shell<enter>top
To get the properties of android build.prop configurationadb shell<enter>getprop ro.build.version.sdk
To Set/replace the properties of android build.prop configurationadb shell<enter>setprop net.dns1 4.4.4.0

Shell commands to get the device stats:

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. 

UseCommand
To get display information of device relating to software and hardware configurationadb shell dumpsys display
To get battery information of device relating to software and hardware configurationadb shell dumpsys battery
To get battery stats information of device relating to software and hardware configurationadb shell dumpsys batterystats

Shell commands to send SMS & take screenshot / to record screen:

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.

UseCommand
To send SMS from android device using ADBadb shell am start -a android.intent.action.SENDTO -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 commandadb shell screencap /sdcard/screenshot.png
To start screen recording using ADB command
Note: To stop the screen recording press CTRL+C or COMMAND+C
adb shell screenrecord /sdcard/movie.mp4
To start screen recording by defining output resolution using ADB command.
Note:1. To stop the screen recording press CTRL+C or COMMAND+C2. Enter resolution values based on the supported resolution of the device.
adb shell screenrecord –size 1440 x 2960 /sdcard/movie.mp4
To start screen recording using ADB command and set recording duration.
Note: Replace ‘36’ with desired value in seconds.
adb shell screenrecord –time-limit 36 /sdcard/movie.mp4
To start screen recording using ADB command and set the bitrate of the video output file.adb shell screenrecord –bit-rate 1500000 /sdcard/movie.mp4

Shell Commands to perform key operations:

Most Android developers and testers want to automate actions on Android devices but it needs a 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:

UseCommand
To press HOME button using ADBadb shell input keyevent 3oradb shell am start -W -c android.intent.category.HOME -a android.intent.action.MAIN
To press BACK button using ADBadb shell input keyevent 4
To press CALL button using ADBadb shell input keyevent 5
To press END CALL button using ADBadb shell input keyevent 6
To to toggle device to ON/OFFadb shell input keyevent 26
To launch camera using ADBadb shell input keyevent 27
To launch default browser using ADBadb shell input keyevent 64
To press enter using ADBadb shell input keyevent 66
To press delete or backspace using ADBadb shell input keyevent 67
To launch contacts list using ADBadb shell input keyevent 207
To turn down brightness level using ADBadb shell input keyevent 220
To turn up brightness level using ADBadb shell input keyevent 221
To perform Cut (ctrl+x) operation on selected item using ADB commandadb shell input keyevent 277
To perform Copy (ctrl+c) operation on selected item using ADB commandadb shell input keyevent 278
To perform Paste operation (ctrl+v) on selected item using ADB commandadb shell input keyevent 279
To pass keycode(keyboard value) unknown/0 using ADBadb shell input keyevent 0
To pass keycode(keyboard value) MENU/SOFT_LEFT using ADBadb shell input keyevent 1
To pass keycode(keyboard value) SOFT_RIGHT using ADBadb shell input keyevent 2
To pass keycode(keyboard value) HOME using ADBadb shell input keyevent 3
To pass keycode(keyboard value) BACK using ADBadb shell input keyevent 4
To pass keycode(keyboard value) CALL using ADBadb shell input keyevent 5
To pass keycode(keyboard value) END CALL using ADBadb shell input keyevent 6
To pass keycode(keyboard value) 0 using ADBadb shell input keyevent 7
To pass keycode(keyboard value) 1 using ADBadb shell input keyevent 8
To pass keycode(keyboard value) 2 using ADBadb shell input keyevent 9
To pass keycode(keyboard value) 3 using ADBadb shell input keyevent 10
To pass keycode(keyboard value) 4 using ADBadb shell input keyevent 11
To pass keycode(keyboard value) 5 using ADBadb shell input keyevent 12
To pass keycode(keyboard value) 6 using ADBadb shell input keyevent 13
To pass keycode(keyboard value) 7 using ADBadb shell input keyevent 14
To pass keycode(keyboard value) 8 using ADBadb shell input keyevent 15
To pass keycode(keyboard value) 9 using ADBadb shell input keyevent 16
To pass keycode(keyboard value) STAR using ADBadb shell input keyevent 17
To pass keycode(keyboard value) POUND using ADBadb shell input keyevent 18
To pass keycode(keyboard value) DPAD_UP using ADBadb shell input keyevent 19
To pass keycode(keyboard value) DPAD_DOWN using ADBadb shell input keyevent 20
To pass keycode(keyboard value) DPAD_LEFT using ADBadb shell input keyevent 21
To pass keycode(keyboard value) DPAD_RIGHT using ADBadb shell input keyevent 22
To pass keycode(keyboard value) DPAD_CENTER using ADBadb shell input keyevent 23
To pass keycode(keyboard value) VOLUME_UP using ADBadb shell input keyevent 24
To pass keycode(keyboard value) VOLUME_DOWN using ADBadb shell input keyevent 25
To pass keycode(keyboard value) POWER using ADBadb shell input keyevent 26
To pass keycode(keyboard value) CAMERA using ADBadb shell input keyevent 27
To pass keycode(keyboard value) CLEAR using ADBadb shell input keyevent 28
To pass keycode(keyboard value) A using ADBadb shell input keyevent 29
To pass keycode(keyboard value) B using ADBadb shell input keyevent 30
To pass keycode(keyboard value) C using ADBadb shell input keyevent 31
To pass keycode(keyboard value) D using ADBadb shell input keyevent 32
To pass keycode(keyboard value) E using ADBadb shell input keyevent 33
To pass keycode(keyboard value) F using ADBadb shell input keyevent 34
To pass keycode(keyboard value) G using ADBadb shell input keyevent 35
To pass keycode(keyboard value) H using ADBadb shell input keyevent 36
To pass keycode(keyboard value) I using ADBadb shell input keyevent 37
To pass keycode(keyboard value) J using ADBadb shell input keyevent 38
To pass keycode(keyboard value) K using ADBadb shell input keyevent 39
To pass keycode(keyboard value) L using ADBadb shell input keyevent 40
To pass keycode(keyboard value) M using ADBadb shell input keyevent 41
To pass keycode(keyboard value) N using ADBadb shell input keyevent 42
To pass keycode(keyboard value) O using ADBadb shell input keyevent 43
To pass keycode(keyboard value) P using ADBadb shell input keyevent 44
To pass keycode(keyboard value) Q using ADBadb shell input keyevent 45
To pass keycode(keyboard value) R using ADBadb shell input keyevent 46
To pass keycode(keyboard value) S using ADBadb shell input keyevent 47
To pass keycode(keyboard value) T using ADBadb shell input keyevent 48
To pass keycode(keyboard value) U using ADBadb shell input keyevent 49
To pass keycode(keyboard value) V using ADBadb shell input keyevent 50
To pass keycode(keyboard value) W using ADBadb shell input keyevent 51
To pass keycode(keyboard value) X using ADBadb shell input keyevent 52
To pass keycode(keyboard value) Y using ADBadb shell input keyevent 53
To pass keycode(keyboard value) Z using ADBadb shell input keyevent 54
To pass keycode(keyboard value) COMMA using ADBadb shell input keyevent 55
To pass keycode(keyboard value) PERIOD using ADBadb shell input keyevent 56
To pass keycode(keyboard value) ALT_LEFT using ADBadb shell input keyevent 57
To pass keycode(keyboard value) ALT_RIGHT using ADBadb shell input keyevent 58
To pass keycode(keyboard value) SHIFT_LEFT using ADBadb shell input keyevent 59
To pass keycode(keyboard value) SHIFT_RIGHT using ADBadb shell input keyevent 60
To pass keycode(keyboard value) TAB using ADBadb shell input keyevent 61
To pass keycode(keyboard value) SPACE using ADBadb shell input keyevent 62
To pass keycode(keyboard value) SYM using ADBadb shell input keyevent 63
To pass keycode(keyboard value) EXPLORER using ADBadb shell input keyevent 64
To pass keycode(keyboard value) ENVELOPE using ADBadb shell input keyevent 65
To pass keycode(keyboard value) ENTER using ADBadb shell input keyevent 66
To pass keycode(keyboard value) DEL using ADBadb shell input keyevent 67
To pass keycode(keyboard value) GRAVE using ADBadb shell input keyevent 68
To pass keycode(keyboard value) MINUS using ADBadb shell input keyevent 69
To pass keycode(keyboard value) EQUALS using ADBadb shell input keyevent 70
To pass keycode(keyboard value) LEFT_BRACKET using ADBadb shell input keyevent 71
To pass keycode(keyboard value) RIGHT_BRACKET using ADBadb shell input keyevent 72
To pass keycode(keyboard value) BACKSLASH using ADBadb shell input keyevent 73
To pass keycode(keyboard value) SEMICOLON using ADBadb shell input keyevent 74
To pass keycode(keyboard value) APOSTROPHE using ADBadb shell input keyevent 75
To pass keycode(keyboard value) SLASH using ADBadb shell input keyevent 76
To pass keycode(keyboard value) AT using ADBadb shell input keyevent 77
To pass keycode(keyboard value) NUM using ADBadb shell input keyevent 78
To pass keycode(keyboard value) HEADSETHOOK using ADBadb shell input keyevent 79
To pass keycode(keyboard value) FOCUS using ADBadb shell input keyevent 80
To pass keycode(keyboard value) PLUS using ADBadb shell input keyevent 81
To pass keycode(keyboard value) MENU using ADBadb shell input keyevent 82
To pass keycode(keyboard value) NOTIFICATION using ADBadb shell input keyevent 83
To pass keycode(keyboard value) SEARCH using ADBadb shell input keyevent 84
To pass keycode(keyboard value) MEDIA_PLAY/PAUSE using ADBadb shell input keyevent 85
To pass keycode(keyboard value) MEDIA_STOP using ADBadb shell input keyevent 86
To pass keycode(keyboard value) NEXT using ADBadb shell input keyevent 87
To pass keycode(keyboard value) PREVIOUS using ADBadb shell input keyevent 88
To pass keycode(keyboard value) MEDIA_REWIND using ADBadb shell input keyevent 89
To pass keycode(keyboard value) MEDIA_FAST_FORWARD using ADBadb shell input keyevent 90
To pass keycode(keyboard value) MUTE using ADBadb shell input keyevent 91
To pass keycode(keyboard value) PAGE UP using ADBadb shell input keyevent 92
To pass keycode(keyboard value) PAGE DOWN using ADBadb shell input keyevent 93
To pass keycode(keyboard value) PICT SYMBOLS using ADBadb shell input keyevent 94
To pass keycode(keyboard value) MOVE_HOME using ADBadb shell input keyevent 122
To pass keycode(keyboard value) MOVE_END using ADBadb shell input keyevent 123

Fastboot commands for flashing:

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

UseCommand
To list all fastboot devicesfastboot devices
To unlock bootloader of connected fastboot devicefastboot oem unlock
To re-lock bootloader of connected fastboot devicefastboot oem lock
To reboot device in fastboot or bootloader mode from fastboot modefastboot reboot bootloader
To flash boot image using fastboot modefastboot flash boot boot.img
To flash recovery image using fastboot modefastboot flash recovery recovery.im
To boot custom Image in device without flashing the image filefastboot boot filename.img

Shell commands to get the device information:

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

UseCommand
To list directory contentadb shell ls
To print size of each file in selected directoryadb shell ls -s
To print list of subdirectories recursivelyadb shell ls -R
To print state of deviceadb get-statе
To print IMEI of connected deviceadb shell dumpsys iphonesybinfo
To print information related to connectivity like TCP Ip and connectionsadb shell netstat
To print information of current working directoryadb shell pwd
To print list of phone featuresadb shell pm list features
To print list of all services of deviceadb shell service list
To print information of application activity by package and activity nameadb shell dumpsys activity <package>/<activity>
To print process statusadb shell ps
To print current display resolution informationadb shell wm size
To print activity of current opened applicationdumpsys window windows | grep -E ‘mCurrentFocus|mFocusedApp’
To list the information of all opened appsadb shell dumpsys package packages
To get the information of particular applicationadb shell dump <name>
To get the path of application by package nameadb shell path <package>
To change battery level of device (emulator)Note: Value can be 0 to 100adb shell dumpsys battery set level <n>
To change battery status of device (emulator)Note: Value can be 0 to 3 which relates to state unknown, charging, discharging, not charging or fulladb shell dumpsys battery set status<n>
To reset battery status of device (emulator)adb shell dumpsys battery reset
To change USB status of device (emulator)Note: Value can be 0 or 1adb shell dumpsys battery set usb <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.

  1. Pingback: -
  2. January 20, 2022

    Testing

    Reply

Leave A Comment

Your email address will not be published. Required fields are marked *