Blog Archives

Finding shell command options and memory usage

Filesystem disk space usage

  • adb shell df


For a list of all the available shell programs, use the following command:

  • adb shell ls /system/bin
Which returned:

  • adb shell ls /system/bin
    • abcc
    • adb
    • am
    • app_process
    • applypatch
    • atrace
    • bmgr
    • bootanimation
    • btmacreader
    • bu
    • bugreport
    • cat
    • chmod
    • chown
    • cmp
    • content
    • cp
    • dalvikvm
    • date
    • dbus-daemon
    • dd
    • debuggerd
    • dexopt
    • df
    • dhcpcd
    • dmesg
    • dnsmasq
    • drmserver
    • du
    • dumpstate
    • dumpsys
    • fsck_msdos
    • getevent
    • getprop
    • glgps
    • grep
    • gzip
    • hd
    • hostapd
    • id
    • ifconfig
    • iftop
    • ime
    • input
    • insmod
    • installd
    • ioctl
    • ionice
    • ip
    • ip6tables
    • iptables
    • keystore
    • kill
    • linker
    • ln
    • log
    • logcat
    • logwrapper
    • ls
    • lsmod
    • lsof
    • make_ext4fs
    • md5
    • mdnsd
    • mediaserver
    • mkdir
    • mksh
    • monkey
    • mount
    • mtpd
    • mv
    • nandread
    • ndc
    • netcfg
    • netd
    • netstat
    • newfs_msdos
    • notify
    • ping
    • pm
    • pppd
    • printenv
    • ps
    • racoon
    • reboot
    • renice
    • requestsync
    • rm
    • rmdir
    • rmmod
    • route
    • run-as
    • schedtest
    • schedtop
    • screencap
    • screenshot
    • sdcard
    • send_bug
    • sendevent
    • sensors-config
    • sensorservice
    • service
    • servicemanager
    • setconsole
    • setprop
    • settings
    • setup_fs
    • sh
    • sleep
    • smd
    • start
    • stop
    • surfaceflinger
    • svc
    • sync
    • system_server
    • tc
    • tf_daemon
    • toolbox
    • top
    • touch
    • uiautomator
    • umount
    • uptime
    • vdc
    • vmstat
    • vold
    • watchprops
    • wipe
    • wpa_supplicant


Turning the output from getevent into something something that can be used

My end goal was to to be able to “doodle” on the android screen, with a script.  I can’t do the math to generate the image I want, so I ran the adb shell command “getevent” then using the mouse, I drew on the screen.

However the output isn’t immediately usable, first there was the minor problem of it containing a colon which would throw an error when I tried to run it.  The second and bigger issue, is that the getevent command captures everything in hexadecimal, but the command sendevent, requires everything to be in decimal.  Since monkeyrunner is basically python (the docs say jython, but I haven’t used anything that advance yet), I wrote a python script, that takes an input file containing a bunch of lines that look like this:

/dev/input/event0: 0003 0000 00000073
/dev/input/event0: 0003 0001 000000a8
/dev/input/event0: 0001 014a 00000001
/dev/input/event0: 0000 0000 00000000
/dev/input/event0: 0003 0001 000000a4

And created a new output file with adb shell commands that look like this:

adb shell sendevent /dev/input/event0 3 0 115
adb shell sendevent /dev/input/event0 3 1 168
adb shell sendevent /dev/input/event0 1 330 1
adb shell sendevent /dev/input/event0 0 0 0
adb shell sendevent /dev/input/event0 3 1 164

Which can be run and do the drawing for me on the screen.  This worked, but running a bunch of adb shell commands is really, really slow.  So I tweaked my python script, and instead have to create something like:

echo Running – signature function
sendevent /dev/input/event0 3 0 115
sendevent /dev/input/event0 3 1 168
sendevent /dev/input/event0 1 330 1
sendevent /dev/input/event0 0 0 0
sendevent /dev/input/event0 3 1 164
sendevent /dev/input/event0 0 0 0

This is copied to the device, and run as a local script and runs at an ok speed (not really fast, but much faster than adb shell commands) – the python script prints out instructions with the exact command to run, to copy the file to the device and what to execute it run it.  I will post the python separately, I am new to this code so the code isn’t prefect, but it works and meets my needs.ew

The steps are

  1. Run the app (I did it in the emulator)
  2. Run the command adb shell getevent, om whatever screen you want to doodle/draw on – the output is dumped to the screen
  3. Capture that output when you are done (copy it, usually by right clicking and choosing mark, highlight the area and then hit enter)
    1. Paste the info into notepad, and save it to any file name you want (i.e. captured.dat)
  4. Run the script
    1. captured.dat
      1. catpured.bat is the input data for the script
  5. The script runs pretty fast and kicks out a file captured.scr (the code can be updated to name the file anything)
    1. The script prints out instructions for coping the script to the device and for running the script, that looks something like this

C:\> raw_captured_sig.dat
Processing complete
File created: raw_captured_sig.scr

Copy file to the device
adb push raw_captured_sig.scr /sdcard/raw_captured_sig.scr

Run the script
adb shell sh /sdcard/raw_captured_sig.scr

adb shell sendevent, sending touch like events

Oh joy – output in hex but I need decimal

Running my test app in the emulator, to figure out where I was “touching” on the screen, I used the command:

adb shell getevent

Which returns something like:

C:\>adb shell getevent
add device 1: /dev/input/event0
name: “qwerty2”
could not get driver version for /dev/input/mouse0, Not a typewriter
could not get driver version for /dev/input/mice, Not a typewriter
/dev/input/event0: 0003 0000 00000073
/dev/input/event0: 0003 0001 000000a8
/dev/input/event0: 0001 014a 00000001

Which returns everything in hexidecimal, but you can’t send these commands directly back, you had to convert them to decimal, so this

adb shell sendevent /dev/input/event0 0003 0000 00000073
adb shell sendevent /dev/input/event0 0003 0001 000000a8
adb shell sendevent /dev/input/event0 0001 014a 00000001

Becomes this:

adb shell sendevent /dev/input/event0 3 0 115
adb shell sendevent /dev/input/event0 3 1 168
adb shell sendevent /dev/input/event0 1 330 1

However my capture for what I need to doodle on the screen is like 905 lines, that need to the colon removed from “event0:” and have the values converted to decimal to actually work.  Working on a script to take care of this formatting for me.


Another great post about this can be found here:

adb shell sendevent (could not open /dev/input/event0:, No such file or directory)

This is still a work in progress to get monkeyrunner to interact with a screen that people need to basically draw on.

I found this command to get back coordinates of what is being touched on the screen:

adb shell getevent

Which returns something like this

add device 1: /dev/input/event0
name: “qwerty2”
could not get driver version for /dev/input/mouse0, Not a typewriter
could not get driver version for /dev/input/mice, Not a typewriter
/dev/input/event0: 0003 0000 00000073
/dev/input/event0: 0003 0001 000000a8
/dev/input/event0: 0001 014a 00000001
/dev/input/event0: 0000 0000 00000000


Trying to send this command back, failed

adb shell sendevent /dev/input/event0: 0003 0000 00000073
adb shell sendevent /dev/input/event0: 0003 0001 000000a8

with this error:

could not open /dev/input/event0:, No such file or directory

After playing around for a bit, I found that the colon was the problem (after event0), removed that the error went away, I don’t see anything on the screen yet, but at least the error is gone.

Correct sytax:

adb shell sendevent /dev/input/event0 0003 0000 00000073
adb shell sendevent /dev/input/event0 0003 0001 000000a8



AdbChimpDevice: Error starting command

I have a simple monkeyrunner script, that runs correctly for that I need, but often hits this error:  AdbChimpDevice: Error starting command, and it doesn’t always happen in the same place.  From the source code I looked at, there was a comment that exception happens a lot, yet in my case the script still ran fine.

Something that can be ignored even though it is ugle

What the error looks like in verbose debugging

[] Error starting command: monkey –port 12345
[]      at
[]      at
[]      at$
[]      at java.util.concurrent.Executors$ Source)
[]      at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
[]      at Source)
[]      at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
[]      at java.util.concurrent.ThreadPoolExecutor$ Source)
[]      at Source)



Get a file listing from the Android Device (sdcard)

You can push or pull files from the device, but to get a file listing just shell to the device (for me I needed a listing of what I had pushed to the sdcard, since it has been a while since I worked with a particular device)

adb shell <enter>

prompt changes to $

cd sdcard <enter>

then ls <enter>



To nuke (delete/remove) a file rm <filename>


Tab completion doesn’t work (at least on my windows machine with just the Android SDK installed)

And there is confirmation when you hit enter the file is gone

Then you can get out of the shell by typing exit

Android adb Commands

A quick list of adb commands for Android Testing (mostly for my reference) – this list will be updated at my testing continues.  If you multiple devices connected you can use “-s” to get information for a particular device – helpful if you have 2 devices connected and only want the logcat output for a single device.

Devices – Get list of connected devices, either real or devices in the emulator

adb devices

List of devices attached
CC96A0133C10    device
781DBA1586BE    device

Install – installing a package to a device, it installs to the only connected device, if one device is connected.

adb install myapp.apk

Reboot – like the name says reboot the device

adb reboot

Remount – this allows you to remount an emulated device  image as writable (so you can change things like the host file

adb remount

Pull – get stuff all the device

adb pull /system/etc/hosts c:\Android\hosts

This example pulls a copy of the hosts file from the device

Push – put stuff on the device

adb push name.txt /sdcard/name.txt

This example pushes a test file called “name.txt” to the “sdcard” – as the same name, but you can change the file name for the destination

Uninstall – remove your installed package

adb uninstall

List installed Packages  – list everything installed on your device

adb shell pm list packages

Logging – log what is going on the device as it is being used

adb logcat

Logging – to clear the log use the “-c” option

adb logcat -c

Logging – log what is going on for a particular device as it is being used

adb -s CC96A0133C10 logcat

Getevent – Capture events being touched on the screen, note it captures in hexadecimal and the values need to be converted to decimal in order to use

adb shell getevent

Run Shell script – How to run a shell script once it is pushed until the android

adb shell sh /sdcard/<script name>

File Listing – to find the files listed on a device (I mostly check  sdcard) – use your standard unix comment ls

adb shell ls

To check the On the SDCARD

adb shell ls /sdcard/