0% found this document useful (0 votes)
22 views10 pages

Connect Your Android Device and Launch A Command Line Window in Advance

The document provides a comprehensive list of command line tools and their usage for Android devices, including commands like adb, am, and various debugging utilities. Each command is described with its purpose and usage examples, covering a wide range of functionalities from managing applications to system performance tracing. It serves as a reference for developers and users looking to interact with Android's command line interface effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views10 pages

Connect Your Android Device and Launch A Command Line Window in Advance

The document provides a comprehensive list of command line tools and their usage for Android devices, including commands like adb, am, and various debugging utilities. Each command is described with its purpose and usage examples, covering a wide range of functionalities from managing applications to system performance tracing. It serves as a reference for developers and users looking to interact with Android's command line interface effectively.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 10

Connect your Android device and launch a command line window in advance.

Then you can try to use all these commands by executing command adb shell.

Commands Desc.

adb Android Debug Bridge

am Activity Manager

app_process Execute a runtime environment for a dalvik class/Jar file.

Apply patches to android files.


usage: applypatch [: ...]
or applypatch -c [ ...]
or applypatch -s
applypatch or applypatch -l

Filenames may be of the form


MTD::::::...
to specify reading from or writing to an MTD partition.

Trace information captured in the folder of /sys/kernel/debug/tracing/


usage: atrace [options]. Measure the system performance and do the analysis. Systrace tool provides more parameters to measure the performance than
atrace.
options include:
-b N use a trace buffer size of N KB
-c trace into a circular buffer
atrace -d trace disk I/O
-f trace CPU frequency changes
-l trace CPU frequency governor load
-s trace the kernel scheduler switches
-t N trace for N seconds [defualt 5]
-w trace the kernel workqueue
-z compress the trace dump

Bluetooth Debuging Utility


Usage:
bluetoothd [OPTION...]

Help Options:
-?, --help Show help options
bluetoothd
Application Options:
-d, --debug=DEBUG Specify debug options to enable
-p, --plugin=NAME,.., Specify plugins to load
-P, --noplugin=NAME,... Specify plugins not to load
-n, --nodetach Don't run as daemon in background
-v, --version Show version information and exit
-u, --udev Run from udev mode of operation

bmgr is a shell tool you can use to interact with the Backup Manager on Android devices.
usage: bmgr [backup|restore|list|transport|run]
bmgr backup PACKAGE
bmgr enable BOOL
bmgr enabled
bmgr list transports
bmgr bmgr list sets
bmgr transport WHICH
bmgr restore TOKEN
bmgr restore TOKEN PACKAGE...
bmgr restore PACKAGE
bmgr run
bmgr wipe PACKAGE

bootanimation Show the boot animation.


This program downloads a patchram files in the HCD format to Broadcom Bluetooth based silicon and combo chips and and other utility functions.
It can be invoked from the command line in the form
<-d> to print a debug log
<--patchram patchram_file="patchram_file">
brcm_patchram_plus <--baudrate baud_rate="baud_rate">
<--bd_addr bd_address="bd_address">
<--enable_lpm>
<--enable_hci>
uart_device_name

btmacreader Bluetooth MAC Reader.

Backup
Options:
-apk, Save APK
-noapk, Save no APK
bu -shared, Save Shared
-noshared, Save no Shared
-system, All Includes System
-nosystem, Not all Includes System
-all, Everything

bugmailer.sh Send Bug Report to Vendor.

bugreport Export all the debug message from Android and Linux layer.

cat -> toolbox Concatenate, a tool to print out the content of a file continually. It's the same usage with Linux.

chmod -> toolbox Change the mode of file. Usage is the same with Linux.

chown -> toolbox Change the owner of a file/folder. Usage is the same with Linux.

cmp -> toolbox Compare the file. Usage is the same with Linux.

content Perform operations on particular content


usage: adb shell content [subcommand] [options]
usage: adb shell content insert --uri --bind [--bind ...]
a content provider URI.
binds a typed value to a column and is formatted:
:: where:
specifies data type such as:
b - boolean, s - string, i - integer, l - long, f - float, d - double
Note: Omit the value for passing an empty string, e.g column:s:
Example:
# Add "new_setting" secure setting with value "new_value".
adb shell content insert --uri content://settings/secure --bind name:s:new_setting --bind value:s:new_value

usage: adb shell content update --uri [--where ]


is a SQL style where clause in quotes (You have to escape single quotes - see example below).
Example:
# Change "new_setting" secure setting to "newer_value".
adb shell content update --uri content://settings/secure --bind value:s:newer_value --where "name='new_setting'"

usage: adb shell content delete --uri --bind [--bind ...] [--where ]
Example:
# Remove "new_setting" secure setting.
adb shell content delete --uri content://settings/secure --where "name='new_setting'"

usage: adb shell content query --uri [--projection ] [--where ] [--sort ]


is a list of colon separated column names and is formatted:
[:...]
is the order in which rows in the result should be sorted.
Example:
# Select "name" and "value" columns from secure settings where "name" is equal to "new_setting" and sort the result by name in ascending order.
adb shell content query --uri content://settings/secure --projection name:value --where "name='new_setting'" --sort "name ASC"

Launch the Dalvik VM to run a Java class in DEX format.


dalvikvm: [options] class [argument ...]
dalvikvm: [options] -jar file.jar [argument ...]

The following standard options are recognized:


-classpath classpath
-Dproperty=value
-verbose:tag ('gc', 'jni', or 'class')
-ea[:... |:]
-da[:... |:]
(-enableassertions, -disableassertions)
-esa
-dsa
(-enablesystemassertions, -disablesystemassertions)
-showversion
-help

The following extended options are recognized:


-Xrunjdwp:
-Xbootclasspath:bootclasspath
-Xcheck:tag (e.g. 'jni')
-XmsN (min heap, must be multiple of 1K, >= 1MB)
-XmxN (max heap, must be multiple of 1K, >= 2MB)
-XssN (stack size, >= 1KB, <= 256KB)
-Xverify:{none,remote,all}
-Xrs
-Xint (extended to accept ':portable', ':fast' and ':jit')

These are unique to Dalvik:


-Xzygote
dalvikvm
-Xdexopt:{none,verified,all,full}
-Xnoquithandler
-Xjnigreflimit:N (must be multiple of 100, >= 200)
-Xjniopts:{warnonly,forcecopy}
-Xjnitrace:substring (eg NativeClass or nativeMethod)
-Xstacktracefile:
-Xgc:[no]precise
-Xgc:[no]preverify
-Xgc:[no]postverify
-Xgc:[no]concurrent
-Xgc:[no]verifycardtable
-XX:+DisableExplicitGC
-X[no]genregmap
-Xverifyopt:[no]checkmon
-Xcheckdexsum
-Xincludeselectedop
-Xjitop:hexopvalue[-endvalue][,hexopvalue[-endvalue]]*
-Xincludeselectedmethod
-Xjitthreshold:decimalvalue
-Xjitblocking
-Xjitmethod:signature[,signature]* (eg Ljava/lang/String\;replace)
-Xjitcheckcg
-Xjitverbose
-Xjitprofile
-Xjitdisableopt
-Xjitsuspendpoll

Configured with: debugger profiler hprof jit(armv7-a) show_exception=1

Dalvik VM init failed (check log file)

Set date value.


date -> toolbox
date -s yyyymmdd, set date on Android

dd -> toolbox Copy, Convert, and Format a file.


Usage: dd [options]
bs=BYTES [block size]
cbs=BYTES [conversion record size]
conv=KEYWORDS [conv option disabled]
count=BLOCKS [block count]
ibs=BYTES [input block size]
if=FILE [read file]
obs=BYTES [output block size]
of=FILE [write file]
seek=BLOCKS [seek blocks]
skip=BLOCKS [skip blocks]
Ex: dd if=/data/local/tmp/1gb bs=64k | dd of=/sdcard/1gb

df -> toolbox List free space on disk

dmesg -> toolbox Output linux debug message

Dump system status


usage: dumpstate [-b soundfile] [-e soundfile] [-o file [-d] [-p] [-z]] [-s]
-o: write to file (instead of stdout)
-d: append date to filename (requires -o)
dumpstate -z: gzip output (requires -o)
-p: capture screenshot to filename.png (requires -o)
-s: write output to control socket (for init)
-b: play sound file instead of vibrate, at beginning of job
-e: play sound file instead of vibrate, at end of job

dumpsys Dump functional state


dumpsys [options]
Execute dumpsys will output all the message in case there's no option specified.
option:
accessibility
account
activity
alarm
appwidget
audio
backup
battery
batteryinfo
bluetooth
bluetooth_a2dp
clipboard
commontime_management
connectivity
content
country_detector
cpuinfo
dbinfo
device_policy
devicestoragemonitor
diskstats
drm.drmManager
dropbox
entropy
gfxinfo
hardware
input
input_method
iphonesubinfo
isms
location
lock_settings
media.audio_flinger
media.audio_policy
media.camera
media.player
meminfo
mount
netpolicy
netstats
network_management
nfc
notification
package
permission
phone
power
samplingprofiler
scheduling_policy
search
sensorservice
serial
servicediscovery
simphonebook
sip
statusbar
SurfaceFlinger
telephony.registry
textservices
throttle
uimode
updatelock
usagestats
usb
vibrator
wallpaper
wifi
wifip2p
window

The getevent tool runs on the device and provides information about input devices and a live dump of kernel input events.
Usage: getevent [-t] [-n] [-s switchmask] [-S] [-v [mask]] [-d] [-p] [-i] [-l] [-q] [-c count] [-r]
[device]
-t: show time stamps
-n: don't print newlines
-s: print switch states for given bits
-S: print all switch states
-v: verbosity mask (errs=1, dev=2, name=4, info=8, vers=16, pos. events=32, props=64)
getevent -> toolbox
-d: show HID descriptor, if available
-p: show possible events (errs, dev, name, pos. events)
-i: show all device info and possible events
-l: label event types and names in plain text
-q: quiet (clear verbosity mask)
-c: print given number of events then exit
-r: print rate events are received
http://source.android.com/tech/input/getevent.html

getprop -> toolbox List some property of Android

To sum up each character in specified file and result the summation.


hd -> toolbox To do hd command repeatedly and to set delay interval between each execution if -r is designated.
Usage: hd [-b base] [-c count] [-r delay] file

id -> toolbox Print uid, gid, and context

TCP/IP command. Assign an address to a network interface and/or configure network interface parameters. ifconfig is typically used at boot time to define
ifconfig -> toolbox
the network address of each interface on a machine.

Show the packet flow for each network interface


iftop -> toolbox
Usage: iftop [ -r repeats] [ -d delay ]

Send string or key event to device


input usage: input [text|keyevent]
input text
input keyevent
Load a module into the kernel at runtime. The module cannot be used after reboot.
insmod -> toolbox
Usage: insmod

IO Control Command between Up and lower layer.


ioctl [-l ] [-a ] [-rdh]
-l Length of io buffer
ioctl -> toolbox -a Size of each argument (1-8)
-r Open device in read only mode
-d Direct argument (no iobuffer)
-h Print help

Configure the Process.


ionice -> toolbox
Usage: ionice [none|rt|be|idle] [prio]

Kill the process


kill -> toolbox usage: kill [-s signame | -signum | -signame] { job | pid | pgrp }
kill -l [exit_status ...]

Create pseudonyms (links) for files, allowing them to be accessed by different names.
ln -> toolbox
ln [-s]

Display specified log information.


USAGE: log [-p priorityChar] [-t tag] message
log -> toolbox
priorityChar should be one of:
v,d,i,w,e

Real time Log for all application running on Android System.


options include:
-s Set default filter to silent.
Like specifying filterspec '*:s'
-f Log to file. Default to stdout
-r [] Rotate log every kbytes. (16 if unspecified). Requires -f
-n Sets max number of rotated logs to , default 4
-v Sets the log print format, where is one of:
brief process tag thread raw time threadtime long

-c clear (flush) the entire log and exit


-d dump the log and then exit (don't block)
-t print only the most recent lines (implies -d)
-g get the size of the log's ring buffer and exit
-b Request alternate ring buffer, 'main', 'system', 'radio'
logcat or 'events'. Multiple -b parameters are allowed and the results are interleaved. The default is -b main -b system.
-B output the log in binary filterspecs are a series of [:priority] where is a log component tag (or * for all) and priority is:
V Verbose
D Debug
I Info
W Warn
E Error
F Fatal
S Silent (supress all output)
'*' means '*:d' and by itself means :v

If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS.


If no filterspec is found, filter defaults to '*:I'

If not specified with -v, format is set from ANDROID_PRINTF_LOG


or defaults to "brief"
List the file and directory at current or specified path.
Usage: ls -l: LIST_LONG; break;
-n:LIST_LONG | LIST_LONG_NUMERIC; break;
-s: LIST_SIZE; break;
ls -> toolbox -R:LIST_RECURSIVE; break;
-d: LIST_DIRECTORIES; break;
-Z: LIST_MACLABEL; break;
-a: LIST_ALL; break;
-F: LIST_CLASSIFY; break;

lsmod -> toolbox List the module in Android device.

lsof -> toolbox List information in /Proc folder which contains all the process information.

md5 -> toolbox MD5 encription tool

mkdir -> toolbox Create a folder.

monkey A automation stress test tool which generates random event for Android device.

Mount a file structure.


mount -> toolbox
Usage: mount [-r] [-w] [-o options] [-t type] device directory

Remove a file.
mv -> toolbox
USAGE: mv

nandread [-d ] [-f file] [-s sparesize] [-vh]


-d Read from
-f Write to
-s Number of spare bytes in file (default 64)
nandread -> toolbox -R Raw mode
-S Start offset (default 0)
-L Length (default 0)
-v Print info
-h Print help

netcfg Configure network interface usage: netcfg [ {dhcp|up|down}]

netstat -> toolbox Print net state

newfs_msdos -> toolbox New a file System with specified format


usage: newfs_msdos [ -options ] special [disktype]
where the options are:
-@ create file system at specified offset
-B get bootstrap from file
-C create image file with specified size
-F FAT type (12, 16, or 32)
-I volume ID
-L volume label
-N don't create file system: just print out parameters
-O OEM string
-S bytes/sector
-a sectors/FAT
-b block size
-c sectors/cluster
-e root directory entries
-f standard format
-h drive heads
-i file system info sector
-k backup boot sector
-m media descriptor
-n number of FATs
-o hidden sectors
-r reserved sectors
-s file system size (sectors)
-u sectors/track

ping Check if the specified host address is online.

pm Package Manager for running Dalvik Class file.

printenv -> toolbox Print Environment Variables and their Values for Android Device

Print the running process with its state.


Usage: ps [options]
-t Show threads
-x Show time
ps -> toolbox
-Z Show MAC Label
-P Show Policy
-p Show Priority
-c Show CPU

reboot -> toolbox Reboot Android Device

Change the priority of a process.


renice -> toolbox
USAGE: renice [[-r] priority pids ...] [-g pid]

Remove a file or folder.


rm -> toolbox
Usage: rm file_name or rm -r folder_name

Remove the folder.


rmdir -> toolbox
Usage: rmdir

Remove a module
rmmod -> toolbox
usage: rmmod

Add or Remove route


route -> toolbox
Ex: route add -net 192.168.1.2 netmask 255.255.255.0 gw 192.168.1.1

Output Android screen


usage: screencap [-hp] [FILENAME]
-h: this message
screencap
-p: save the file as a png.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.

Output Android screen


usage: screenshot [-s soundfile] filename.png
screenshot
-s: play a sound effect to signal success
-i: autoincrement to avoid overwriting filename.png

Send a event trigger to specified device with type, code, and value. E.g. Touch, or Key.
sendevent -> toolbox
Usage: sendevent [device] [type] [code] [value].

Service operation
Usage: service [-h|-?]
service list
service check SERVICE
service
service call SERVICE CODE [i32 INT | s16 STR] ...
Options:
i32: Write the integer INT into the send parcel.
s16: Write the UTF-16 string STR into the send parcel.

setconsole [-d ] [-v ] [-gtncpoh]


setconsole -> toolbox -d Use instead of /dev/tty0
-v Switch to virtual console
-g Switch to graphics mode
-t Switch to text mode
-n Create and switch to new virtual console
-c Close unused virtual consoles
-p Print new virtual console
-o Print old virtual console
-h Print help

Set the Android property.


setprop -> toolbox
Usage: setprop

sh -> mksh Execute a shell script.

sleep -> toolbox Interval of next action/command (seconds)

start -> toolbox Start a specified service

stop -> toolbox Stop a specified service

Copy host->device only if changed. adb sync is a tool which may be used to copy files from the computer to the device if the files has been changed. By
default the command will synchronize /data and /system unless one option is specified. For the command to operate properly a system variable must be
sync -> toolbox created and defined. ANDROID_PRODUCT_OUT must designate the full actual path to the directory containing a file structure with system and/or data
subfolders containing the files and folders changed.
Usage: sync [ ]

Check if the specified command existed.


toolbox
Usage: toolbox command_name

Display usage of thread or process.


Usage: top [ -m max_procs ] [ -n iterations ] [ -d delay ] [ -s sort_column ] [ -t ] [ -h ]
-m num Maximum number of processes to display.
-n num Updates to show before exiting.
top -> toolbox
-d num Seconds to wait between updates.
-s col Column to sort by (cpu,vss,rss,thr).
-t Show threads instead of processes.
-h Display this help screen.

Unmount the device


umount -> toolbox
Usage: umount device_path

uptime -> toolbox The up time since last boot. The information includes up, idle, and sleep time.

Virtual Meomory Statistics


Usage: vmstat [ -h ] [ -n iterations ] [ -d delay ] [ -r header_repeat ]
-n iterations How many rows of data to print.
vmstat -> toolbox -d delay How long to sleep between rows.
-r header_repeat How many rows to print before repeating
the header. Zero means never repeat.
-h Displays this help screen.

vold Manage the device on Android. The function is similar with udev in Linux.

watchprops -> toolbox Monitor the change of property and list them. The properties can be viewed by executing getprop and set by executing setprop.

Erase the system or data


Usage: wipe
wipe -> toolbox
system means '/system'
data means '/data'

Configure WLAN
usage:
wpa_supplicant wpa_supplicant [-BddhKLqqstuvW] [-P] [-g] \
-i -c [-C] [-D] [-p] \
[-b] [-f] [-e] \
[-o] [-O] \
[-N -i -c [-C] [-D] \
[-p] [-b] ...]

drivers:
nl80211 = Linux nl80211/cfg80211
options:
-b = optional bridge interface name
-B = run daemon in the background
-c = Configuration file
-C = ctrl_interface parameter (only used if -c is not)
-i = interface name
-d = increase debugging verbosity (-dd even more)
-D = driver name (can be multiple drivers: nl80211,wext)
-e = entropy file
-g = global ctrl_interface
-K = include keys (passwords, etc.) in debug output
-t = include timestamp in debug messages
-h = show this help text
-L = show license (GPL and BSD)
-o = override driver parameter for new interfaces
-O = override ctrl_interface parameter for new interfaces
-p = driver parameters
-P = PID file
-q = decrease debugging verbosity (-qq even less)
-v = show version
-W = wait for a control interface monitor before starting
-N = start describing new interface
example:
wpa_supplicant -Dwext -iwlan0 -c/etc/wpa_supplicant.conf

You might also like