Coming from a Linux world, it was easy for me to use the Android Debug Bridge (adb) shell. Here are some ADB Tips and Tricks for you.

By default, it’s a Bourne Shell (sh) that opens when you connect to your phone.

Directory listing:

I always hate it when I want to see the content of a folder and I get to see funny characters instead. This is because the default Linux terminal supports color codes, while adb shell doesn’t. There are other types of interfaces to use instead of connecting from command prompt, but I rather keep my tools to the minimum. Thus, there are some workarounds:

# alias ls='ls –color=none'

This will enable all your ls commands during the current session to be actually ls –color=none. I usually go for the extended version of it:

# alias ls='ls –color=none -al'

Now you will also see hidden folders, together with a rather comprehensive description about them. Another way to do this is to make sure you type like this every time you want to see the content of the folder:

# ls –color=none -al

Searching for a file:

# find / -name filename

Just replace filename with what you are searching for. Careful, it’s case sensitive! For example, on InsertCoin 1.9c, searching for bootanimation.zip should be done:

# find / -type f -name bootanimation.zip
find / -type f -name bootanimation.zip
/mnt/sdcard/dropbox/Public/Cheshire/bootanimation.zip
/mnt/sdcard/bootanimation.zip
/system/sd/.customize/resource/bootanimation.zip

As you can see, I have the file bootanimation.zip in three directories, twice on the fat32 partition of the SD card and once on the ext4 partition.

Kernel messages

The same as in Linux, the command is

# dmesg

There’s a lot of information to see at one time, but luckily you can filter it (by the use of grep and tail for example). For example, to see the battery messages, I always use:

# dmesg | grep batt | tail -n 10
dmesg | grep batt | tail -n 10
[14237.468658] batt: 86%, 4094 mV, 233 mA (233 avg), 31.8 C, 1171 mAh
[14287.522918] batt: 86%, 4099 mV, 233 mA (232 avg), 31.8 C, 1174 mAh
[14337.577728] batt: 86%, 4099 mV, 232 mA (228 avg), 31.8 C, 1176 mAh
[14387.632354] batt: 87%, 4099 mV, 230 mA (231 avg), 32.0 C, 1180 mAh
[14437.694732] batt: 87%, 4104 mV, 231 mA (230 avg), 32.0 C, 1184 mAh
[14487.748870] batt: 87%, 4104 mV, 231 mA (231 avg), 32.1 C, 1187 mAh
[14537.801940] batt: 88%, 4109 mV, 231 mA (230 avg), 32.1 C, 1190 mAh
[14587.860931] batt: 88%, 4109 mV, 228 mA (230 avg), 32.1 C, 1193 mAh
[14637.917572] batt: 88%, 4109 mV, 229 mA (225 avg), 32.1 C, 1196 mAh
[14687.972503] batt: 88%, 4114 mV, 228 mA (228 avg), 32.1 C, 1200 mAh

As a sidenote, the first number displayed is the time in second since the phone was booted. You can also see it (in days, hours, minutes) with:

# uptime
uptime
17:08:30 up 4:04, load average: 1.02, 1.06, 1.12

This is done with the command:

# ln -s source destination

For example:

# ln -s /system/xbin/busybox /system/xbin/ifconfig

You can always check it after with:

# ls -al –color=none /system/xbin/ifconfig
lrwxrwxrwx 1 0 0 20 Feb 15 19:44 /system/xbin/ifconfig -> /system/xbin/busybox

Which is the full path to a command

If you need to know which ifconfig will be used by default (assuming for instance, you have he standard one and the busybox one) just ask the Bourne Shell. Same applies if you need to know the full path to the command:

# which ifconfig
which ifconfig
/system/xbin/ifconfig