Adb Commands1
Adb Commands1
adb devices
Prints a list of all attached emulator/device
adb devices
In response, return serial number and state
e4b25377
device
emulator-5554 device
Adb forward
forward socket connections
adb forward <local> <remote>
adb forward tcp:8000 tcp:9000 set up forwarding of host port 8000 to emulator/device port 9000
Prerequisites: Enable USB debugging on thee device.
adb kill-server
terminates the adb server process
adb kill-server
Notes: kill the server if it is running. (terminal adb.exe process)
Package Manager
adb install
Pushes an Android application (specified as a full path to an .apk file) to an emulator/device.
adb install [option] <path>
adb uninstall
Removes a package from the emulator/device.
adb uninstall [options] <PACKAGE>
adb shell pm list packages -i See the installer for the packages.
adb shell pm list packages -u Also include uninstalled packages.
adb shell pm list packages --user <USER_ID> The user space to
query.
File Manager
adb pull
Download a specified file from an emulator/device to your computer.
adb pull <remote> [local]
adb push
Upload a specified file from your computer to an emulator/device.
adb shell ls
list directory contents
ls [options] <directory>
STEP 1.
adb shell
STEP 2.
ls
ls -a do not hide entries starting with
ls -i print index number of each file
ls -s print size of each file, in blocks
ls -n list numeric UIDs and GIDs
ls -R list subdirectories recursively
Notes: press Ctrl-C to stop
adb shell ls
list directory contents
ls [options] <directory>
STEP 1.
adb shell
STEP 2.
ls
ls -a do not hide entries starting with
ls -i print index number of each file
ls -s print size of each file, in blocks
ls -n list numeric UIDs and GIDs
ls -R list subdirectories recursively
Notes: press Ctrl-C to stop
adb shell cd
change directory
cd <directory>
STEP 1.
adb shell
STEP 2.
cd /system
adb shell rm
remove files or directories
rm [options] <files or directory>
STEP 1.
adb shell
STEP 2.
rm /sdcard/test.txt
mkdir /sdcard/tmp
mkdir -m 777 /sdcard/tmp set permission mode
mkdir -p /sdcard/tmp/sub1/sub2 create parent directories as
needed
adb shell
STEP 2.
touch /sdcard/tmp/test.txt
ls /sdcard/tmp
pwd
adb shell cp
copy files and directories
cp [options] <source> <dest>
STEP 1.
adb shell
STEP 2.
cp /sdcard/test.txt /sdcard/demo.txt
adb shell mv
move or rename files
adb shell
STEP 2.
Network
db shell netstat
network statistics
netstat
STEP 1.
adb shell
STEP 2.
netstat
adb shell
STEP 2.
ping www.google.com
Notes: press Ctrl-C to stop ping
ping www.google.com -c 4
adb shell
STEP 2.
netcfg
adb shell ip
show, manipulate routing, devices, policy routing and tunnels
ip [ OPTIONS ] OBJECT
OBJECT := { link | addr | addrlabel | route | rule | neigh | ntable |tunnel | tuntap | maddr | mroute |
mrule | monitor | xfrm |netns | l2tp }
OPTIONS := { -V[ersion] | -s[tatistics] | -d[etails] | -r[esolve] |-f[amily] { inet | inet6 | ipx | dnet | link } |l[oops] { maximum-addr-flush-attempts } |-o[neline] | -t[imestamp] | -b[atch] [filename] |-rc[vbuf] [size]}
STEP 1.
adb shell
STEP 2.
Logcat
adb logcat
Prints log data to the screen.
adb logcat
Notes: press Ctrl-C to stop monitor
adb logcat *:V lowest priority, filter to only show Verbose level
adb logcat *:D filter to only show Debug level
adb logcat *:I filter to only show Info level
adb logcat *:W filter to only show Warning level
adb logcat *:E filter to only show Error level
adb logcat *:F filter to only show Fatal level
adb logcat *:S Silent, highest priority, on which nothing is ever
printed
Notes: Battery Historian converts that data into an HTML visualization. STEP 1 adb shell dumpsys
batterystats > batterystats.txt STEP 2 python historian.py batterystats.txt > batterystats.html
Screenshot
System
adb root
restarts the adbd daemon with root permissions
adb root
Notes: adbd cannot run as root in production builds (test in emulator)
adb sideload
flashing/restoring Android update.zip packages.
db shell ps
adb shell
STEP 2.
ps
ps -p
adb shell
STEP 2.
top
Notes: (press Ctrl-C to stop monitor)
top -t Show threads instead of processes.
adb shell
STEP 2.
getprop
getprop ro.build.version.sdk
getprop ro.chipname
getprop | grep adb
See Also adb shell setprop
adb shell
STEP 2.