To get started, you need to enable USB Debugging mode on your device by navigating to Settings > About Phone > Build number (tap it 7 times to become a developer) > Settings > Developer Options > USB Debugging. You will also need to download Android SDK Platform Tools (ADB & Fastboot) and connect your device to the computer using a USB cable.
For Mac users, you can set up ADB on Mac using Homebrew. Additionally, you can download and install the Android USB driver on your computer (optional).
Furthermore, these commands can also be executed wirelessly using ADB over Wi-Fi. To learn more about granting special permissions over ADB, click here: How to Grant Permissions over ADB. You can also check out this guide to learn how to grant permissions without root or ADB: How to Grant Permissions without root wirelessly
Below is a comprehensive list of ADB commands that can be executed via the command prompt or terminal when your Android device is connected to your computer with all the required settings in place. Make sure you have fulfilled the prerequisites mentioned earlier before proceeding with these commands.
- adb help: displays help documentation on ADB commands
- adb devices: lists all Android devices correctly connected to the PC via ADB
- adb usb: shows all connected Android devices or emulators to the PC using USB
- adb reboot: restarts the Android device to the system
- adb reboot bootloader: reboots the device into fastboot or bootloader mode
- adb recovery: gets the Android device into recovery mode
- adb sideload update.zip: used to manually install updates using recovery mode when the ZIP file is on the computer, not in mobile
- adb install: manually installs APK files on Android using ADB
- adb install appname.apk: installs an APK file, replacing the name with the particular APK file name
- adb install -r appname.apk: re-installs or updates an APK to a newer version on Android using ADB
- adb install -s appname.apk: installs an APK in the external SD Card, if supported by the application
- adb uninstall com.package.gg : uninstalls the app package, replacing the package name with your desired one
- adb uninstall -k com.package.gg: uninstalls the app keeping the data and cache untouched
- adb jdwp: displays a full list of JDWP processes on the Android
- adb bugreport: checks the dumpsys, dumpstate, and logcat data
- adb logcat: displays full log data on the screen
- adb get-serialno: displays the ADB instance serial number string associated with the device
- adb wait-for-device: programs the device to wait for some time until another process is done
- adb get-state: shows the device status in the command prompt or terminal
- adb start-server: starts the ADB server process
- adb kill-server: terminates the ADB server process
- adb backup: creates a full backup of your Android device and saves it to the computer
- adb restore: restores the backup
- adb connect ip_address_of_device: connects the IP address of your Android device to the computer by changing the IP address in the code
Transferring files between your Android device and computer is made possible through the use of push and pull commands in ADB. In order to pull a file from your device to your computer, you will need to specify the full file path in the command. For instance, if you want to pull a file called "abc.txt" located in the system/app directory, the command should be executed as follows:
adb pull /system/app/abc.txt
On the other hand, pushing files from your computer to your Android device using ADB requires you to specify the source path and target path in the command. You must provide the full path of the file, including the file extension. For example, if you want to push "abc.txt" from your local path to the /sdcard/apps directory, the command should be executed as follows:
adb push /local/path/abc.txt /sdcard/apps/
The following list comprises all ADB Shell commands which can be executed through the command prompt or terminal when the Android device is connected to a PC with necessary settings. These commands help you control the device remotely. The ADB Shell commands include:
- adb shell: Opens the remote shell command console on the device.
- adb shell wm density: Used to change the pixel density of your Android device.
- adb shell pm list packages: Displays the package name of all installed apps on your Android.
- adb shell pm list packages -s: Shows the package name of all system apps installed on your Android.
- adb shell pm list packages -3: Lists all 3rd party apps installed on your Android.
- adb shell pm list packages -d: Displays the list of disabled apps on your Android.
- adb shell pm list packages -e: Displays the enabled (active) apps on your Android with their package names.
- adb shell pm list packages -u: Shows the list of all the apps that you uninstalled from your Android with their installed pages.
- cd /system: Changes the directory to /system.
- rm -f /sdcard/abc.txt: Deletes a file. You can replace abc.txt with the desired file name and its extension.
- rm -d /sdcard/folder: Deletes a folder. Replace folder with your desired folder name.
- mkdir /sdcard/Folder1: Creates a new folder named "Folder1" under /sdcard.
- netstat: Allows you to check network statistics on your Android device using ADB.
- ip -f inet addr show wlan0: Displays the Wi-Fi IP address of the device.
- top: Monitors the running CPU process on your Android device.
- getprop ro.build.version.sdk: Fetches the property of Android's build.prop configuration.
- setprop net.dns1 126.96.36.199: Used to set the values of build.prop configuration and change the properties.
You can easily change the Pixel density of your Android device’s screen using adb shell wm density commands. In order to do that, you need to know the actual Pixel density of your device.If you want to set a lower resolution, you can check out the following examples (remember, the values may vary from device to device):
for 1080p (FHD)
- adb shell wm size 1080x2220
- adb shell wm density 480
for 720p (HD)
- adb shell wm size 720x1560
- adb shell wm density 350
Depending on your device, you can set the values, whichever looks excellent for you.
adb shell pm uninstall -k –user 0 package.name.com
Simply substitute "package.name.com" with the actual name of the package you want to remove. This technique is the most efficient approach for uninstalling bloatware that comes preinstalled with the system and can't usually be uninstalled via the app menu.
By executing the dumpsys command, you can obtain comprehensive information about the hardware and software configuration of your Android device. Additionally, you can use it to obtain specific details about various device elements like the battery, display, and battery statistics.
- adb shell dumpsys display: Retrieves detailed information related to the display system of your Android device, such as display metrics, screen resolution, orientation, and more.
- adb shell dumpsys battery: Provides information regarding the battery status, including level, charging state, and other details.
- adb shell dumpsys batterystats: Presents battery usage statistics, which can help identify applications that consume the most battery and optimize device usage accordingly.
You can use the ADB Shell KeyEvent commands to trigger certain functions on your Android device, such as hardware buttons and UI options. These commands should only be used by advanced users who know how to tweak VM heap to improve performance.
For example, you can use the following codes to perform actions such as going back, making a call, turning the device on/off, opening the browser, and more:
- Home button: adb shell input keyevent 3
- Back button: adb shell input keyevent 4
- Call: adb shell input keyevent 5
- End call: adb shell input keyevent 6
- Turn device on/off: adb shell input keyevent 26
- Camera: adb shell input keyevent 27
- Open browser: adb shell input keyevent 64
- Enter: adb shell input keyevent 66
- Delete (backspace): adb shell input keyevent 67
- Contacts: adb shell input keyevent 207
- Brightness down/up: adb shell input keyevent 220 / 221
- Cut/Copy/Paste: adb shell input keyevent 277 / 278 / 279
The following ADB Shell command can be used to send an SMS from an Android device while it's connected to a computer. Replace "CCXXXXXXXXXX" with the recipient's phone number and "SMS BODY GOES HERE" with the message you want to send:
adb shell am start -a android.intent.action.SENDTO -d sms:CCXXXXXXXXXX --es sms_body "SMS BODY GOES HERE" --ez exit_on_sent true
After executing the above command, you can simulate pressing the "send" button on your device by running these two commands:
adb shell input keyevent 22
adb shell input keyevent 66
This ADB Shell command allows you to take a screenshot of your Android phone and quickly transfer it to your computer:
To take a screenshot, use the command:
adb shell screencap /sdcard/screenshot.png
After executing the above command, you can retrieve the screenshot by using the command:
adb pull /sdcard/screenshot.png
This command is useful for users who want to take screenshots of their Android device without having to use third-party applications.
You can use the ADB Shell command to capture a video of your Android device's screen and transfer it to your computer. The screen recording feature is available on Android devices running version 4.4 Kitkat and above.
To start recording your screen, run the command
"adb shell screenrecord /sdcard/record.mp4"
and then press "Ctrl+C" or "Command+C" to stop recording.
The default recording duration is limited to 3 minutes, but you can customize the duration, resolution, and video bitrate using additional commands.
For instance, you can set the screen resolution to 1920x1080 pixels by running
"adb shell screenrecord --size 1920x1080 /sdcard/record.mp4"
and limit the recording duration to 360 seconds with
adb shell screenrecord --time-limit 360 /sdcard/record.mp4
You can also adjust the video bitrate to 4MBPS with
adb shell screenrecord --bit-rate 4000000 /sdcard/record.mp4
To copy a file or folder from one location to another, use the "cp" command followed by the source file/folder and the destination folder:
adb shell cp /sdcard/myfile.txt /sdcard/myfolder/
To move a file or folder from one location to another, use the "mv" command followed by the source file/folder and the destination folder:
adb shell mv /sdcard/myfile.txt /sdcard/myfolder/
To rename a file, use the "mv" command followed by the original file name and the new file name:
adb shell mv /sdcard/oldfile.txt /sdcard/newfile.txt
To create a copy of a file with a new name, use the "cp" command followed by the original file name and the new file name:
adb shell cp /sdcard/oldfile.txt /sdcard/newfile.txt
- fastboot devices: Shows a list of Android devices connected to the PC in Fastboot Mode.
- fastboot device: This command allows you to specify a device in case there are multiple devices connected to the PC in Fastboot Mode.
- fastboot oem unlock: Allows you to unlock the bootloader of your Android device if your OEM permits it. This command is usually used when rooting or installing custom ROMs.
- fastboot oem lock: Relocks the bootloader of your Android device. This command is useful if you want to return your device to its stock state.
- fastboot reboot bootloader: Reboots the device into Fastboot Mode from Fastboot Mode itself. This command is sometimes necessary when flashing certain image files.
- fastboot flash: This command is used to flash images to your Android device, such as OTA ZIP files or TWRP images.
- fastboot flash boot boot.img: Use this command to flash a boot image on your Android device. For example, you might use this command to flash a Magisk-patched boot image to root your phone.
- fastboot reboot: This command reboots the device normally.
- fastboot flash recovery recovery.img: Use this command to flash recovery images like TWRP on your Android device.
- fastboot boot filename.img: This command is used to boot your device using a particular image file without flashing it permanently. This can be useful for testing purposes before making a permanent flash.