ADB
Android Debug Bridge (adb) is a command line tool that lets you communicate with an emulator or connected Android device. You can find the adb tool in android sdk/platform-tools or Download ADB Kits.
How do I find ADB located
Download the latest version of the platform-tools (about 8 MB), If you installed Android Studio (Android SDK), the default path is C:\Users\YOUR-NAME\AppData\Local\Android\Sdk in Windows.
Windows
%LocalAppData%\Android\Sdk\platform-tools
MAC
~/Library/Android/Sdk
Linux
~/Android/Sdk
ADB Debugging
adb devices
List of devices attached
adb devicesList connected devices (-l for long output)
adb devices -ladb forward
list all forward socket connections
adb forward --listset up port forwarding
adb forward tcp:6123 tcp:7123adb kill-server
terminates the adb server process
adb kill-serverWireless
adb connect
STEP 1.
Set the target device to listen for a TCP/IP connection on port 5555
disconnect the USB cable from the Android device
adb tcpip 5555STEP 2.
Connect to a device over Wi-Fi.
find your Android device IP address at Settings > About phone > Status > IP address
adb connect 192.168.100.12STEP 3.
Confirm that your host computer is connected to the Android device over Wi-Fi
adb devicesList of devices attached 192.168.100.12:5555 device
adb usb
Restarting in USB mode
adb usbPackage Manager
adb install
app installation - push a single package to the device and install it
adb install test.apkapp installation - push multiple APKs to the device for a single package and install them
adb install-multiple test.apk test2.apkapp installation - push one or more packages to the device and install them atomically
adb install-multi-package test.apk demo.apkreplace existing application
reinstall an existing app, keeping its data
adb install -r test.apkallow test packages
adb install -t test.apkallow version code downgrade
debuggable packages only
adb install -d test.apkgrant all runtime permissions
Grant all permissions listed in the app manifest
adb install -g test.apkcause the app to be installed as an ephemeral install app
adb install --instant test.apkuse fast deploy
adb install --fastdeploy test.apkalways push APK to device and invoke Package Manager as separate steps
adb install --no-streaming test.apkadb uninstall
remove this app package from the device
adb uninstall test.apkKeep the data and cache directories around after package removal
adb uninstall -k test.apkadb shell pm path
Print the path to the .apk of the given installed package name
adb shell pm path com.android.chromeadb shell pm clear
Deletes all data associated with a package.
adb shell pm clear com.test.abcNotes: clearing app data, cache
File Manager
adb pull
copy files/dirs from device
To copy a file or directory and its sub-directories from the Android device
adb pull /mnt/sdcard/Download/test.apk pc.apkpreserve file timestamp and mode.
adb pull -a /mnt/sdcard/Download/test.apk pc.apkadb push
copy local files/directories to Android device
adb push pc.apk /mnt/sdcard/Download/test.apkonly push files that are newer on the host than the Android device
adb push --sync pc.apk /mnt/sdcard/Download/test.apkadb shell ls
List Files and Directories
adb shell ls /system/binall files including .hidden
adb shell ls -adirectory, not contents
adb shell ls -drecursively list in subdirs
adb shell ls -R /mnt/sdcard/Downloadadb shell cd
change directory
adb shell cd /mnt/sdcard/Downloadadb shell rm
rm is a command-line utility for removing files, directories and symbolic links
adb shell rm /mnt/sdcard/Download/test.apkForce: remove without confirmation, no error if it doesn't exist
adb shell rm -f /mnt/sdcard/Download/test.apkInteractive: prompt for confirmation
adb shell rm -i /mnt/sdcard/Download/test.apkRecursive: remove directory contents
adb shell rm -rR /mnt/sdcard/DownloadVerbose
adb shell rm -v /mnt/sdcard/Download/test.apkadb shell mkdir
make directories
mkdir /sdcard/tmpmkdir -m 777 /sdcard/tmp set permission modemkdir -p /sdcard/tmp/sub1/sub2 create parent directories as neededadb shell touch
the touch command is a standard command used in UNIX/Linux operating system which is used to create, change and modify timestamps of a file
adb shell touch /mnt/sdcard/Download/test.txtadb shell pwd
printing the current working directory
adb shell pwdadb shell cp
copy files and directories
cp [options] <source> <dest>
STEP 1.
adb shellSTEP 2.
cp /sdcard/test.txt /sdcard/demo.txt
adb shell mv
moves files or directories from one place to another
adb shell mv /mnt/sdcard/Download/test.txt /mnt/sdcard/DCIM/test.txtForce copy by deleting destination file
adb shell mv -f /mnt/sdcard/Download/test.txt /mnt/sdcard/DCIM/test.txtInteractive, prompt before overwriting existing DEST
adb shell mv -i /mnt/sdcard/Download/test.txt /mnt/sdcard/DCIM/test.txtNo clobber (don't overwrite DEST)
adb shell mv -n /mnt/sdcard/Download/test.txt /mnt/sdcard/DCIM/test.txtNetwork
adb shell netstat
Display networking information.
Default is netstat -tuwx
adb shell netstatRouting table
adb shell netstat -rAll sockets (not just connected)
adb shell netstat -aListening server sockets
adb shell netstat -lTCP sockets
adb shell netstat -tUDP sockets
adb shell netstat -uRaw sockets
adb shell netstat -wUnix sockets
adb shell netstat -xExtended info
adb shell netstat -eDon't resolve names
adb shell netstat -nWide display
adb shell netstat -wShow PID/program name of sockets
adb shell netstat -padb shell ping
ping (Packet Internet Groper) is a network administration utility used to testing, and diagnosing network connectivity issues
adb shell pingNotes: press Ctrl-C to stop ping
Specifies the number of echo Request messages sent
adb shell ping -c 4Specifies the amount of time, in milliseconds, to wait for the echo Reply message that corresponds to a given echo Request message to be received
The default time-out is 4000 (4 seconds)
adb shell ping -W 200 127.0.0.1Interval in seconds
By default, interval is 1 second
adb shell ping -i 2 127.0.0.1adb shell netcfg
Network configuration.
adb shell netcfgNotes: /system/bin/sh: netcfg: not found in Android M or higher.
Display or configure network interface.
adb shell ifconfigadb shell ip
get wlan0 (Wi-Fi) IP address
adb shell ip addr show wlan0route table
adb shell ip routeARP table
adb shell ip neighbourLogcat
adb logcat
Prints log data to the screen.
adb logcat [option] [filter-specs]
adb logcatNotes: press Ctrl-C to stop monitor
adb logcat *:V lowest priority, filter to only show Verbose leveladb logcat *:D filter to only show Debug leveladb logcat *:I filter to only show Info leveladb logcat *:W filter to only show Warning leveladb logcat *:E filter to only show Error leveladb logcat *:F filter to only show Fatal leveladb logcat *:S Silent, highest priority, on which nothing is ever printedadb logcat -b <Buffer>
adb logcat -b radio View the buffer that contains radio/telephony related messages.adb logcat -b event View the buffer containing events-related messages.adb logcat -b main defaultadb logcat -c Clears the entire log and exits.adb logcat -d Dumps the log to the screen and exits.adb logcat -f test.logs Writes log message output to test.logs .adb logcat -g Prints the size of the specified log buffer and exits.adb logcat -n <count> Sets the maximum number of rotated logs to <count>. Notes: The default value is 4. Requires the -r option.
adb logcat -r <kbytes> Rotates the log file every <kbytes> of output.Notes: The default value is 16. Requires the -f option.
adb logcat -s Sets the default filter spec to silent.adb logcat -v <format>
adb logcat -v brief Display priority/tag and PID of the process issuing the message (default format).adb logcat -v process Display PID only.)adb logcat -v tag Display the priority/tag only.adb logcat -v raw Display the raw log message, with no other metadata fields.adb logcat -v time Display the date, invocation time, priority/tag, and PID of the process issuing the message.adb logcat -v threadtime Display the date, invocation time, priority, tag, and the PID and TID of the thread issuing the message.adb logcat -v long Display all metadata fields and separate messages with badb shell dumpsys
To dump all services
adb shell dumpsysonly list services, do not dump them
adb shell dumpsys -lGet Android device battery info
adb shell dumpsys batteryadb shell dumpstate
dump Android device state.
adb shell dumpstatedumpstate not working with Android 10.
dump the Android device dumpstate, dumpsys and logcat outs.
adb bugreportScreenshot
adb shell screencap
The screencap command is a shell utility for taking a screenshot of a device display
adb shell screencap /mnt/sdcard/Download/test.pngNotes: If FILENAME is not given, the results will be printed to stdout.
To copy screenshot from Android Device.
adb pull /mnt/sdcard/Download/test.png test.pngadb shell screenrecord
Android screenrecord v1.2. Records the device's display to a .mp4 file
adb shell screenrecord /mnt/sdcard/Download/test.mp4Recording continues until Ctrl-C is hit or the time limit is reached
Set the video size, e.g. "1280x720". Default is the device's main display resolution (if supported), 1280x720 if not. For best results, use a size supported by the AVC encoder.
adb shell screenrecord --size 1280x720 /mnt/sdcard/Download/test.mp4Set the video bit rate, in bits per second. Value may be specified as bits or megabits, e.g. '4000000' is equivalent to '4M'. Default 20Mbps.
adb shell screenrecord --bit-rate 4000000 /mnt/sdcard/Download/test.mp4Rotates the output 90 degrees. This feature is experimental.
adb shell screenrecord --rotate /mnt/sdcard/Download/test.mp4Add additional information, such as a timestamp overlay, that is helpful in videos captured to illustrate bugs.
adb shell screenrecord --bugreport /mnt/sdcard/Download/test.mp4Set the maximum recording time, in seconds. Default / maximum is 180
adb shell screenrecord --time-limit=120 /mnt/sdcard/Download/test.mp4Display interesting information on stdout
adb shell screenrecord --verbose /mnt/sdcard/Download/test.mp4Audio is not recorded with the video file. Rotation of the screen during recording is not supported. If the screen does rotate during recording, some of the screen is cut off in the recording.
System
adb root
restart adbd with root permissions
adb rootrestart adbd without root permissions
adb unrootadb sideload
sideload the given full OTA package
adb sideload /mnt/sdcard/Download/ota.zipNo Root Required
adb shell ps
List processes. Which processes to show (selections may be comma separated lists)
adb shell psAll processes
adb shell ps -Afilter PIDs (--pid)
adb shell ps -p 1256Show threads
adb shell ps -tadb shell top
Show process activity in real time
adb shell topCursor LEFT/RIGHT to change sort, UP/DOWN move list, space to force update, R to reverse sort, Q to exit
Show threads
adb shell top -HShow FIELDS (def PID,USER,PR,NI,VIRT,RES,SHR,S,%CPU,%MEM,TIME+,CMDLINE)
adb shell top -o %CPU,%MEM,TIME+Maximum number of tasks to show
adb shell top -m 50adb shell getprop
Gets an Android system property, or lists them all
adb shell getpropShow property types instead of values
adb shell getprop -TGet SIM Operator
adb shell getprop gsm.sim.operator.alphaGet Device IEMI
adb shell getprop ro.ril.oem.imeiadb shell setprop
set property service
setprop <key> <value>
STEP 1.
adb shell STEP 2.
setprop service.adb.tcp.port 5555
Last updated
Was this helpful?