[Desire General] mercianary:
Here you will find a list of some shell commands you can use on your android phone, either with a terminal emulator or over adb shell from your PC. I would recommend using connectbot as your terminal emulator.

The commands listed are in no way limited to what is described below, I am just scraping the surface here. For more information on these commands type ' --help' after your command, e.g. 'mount --help' or use google, most of these commands are exactly the same as what you would find on any Linux system, so you will find EXTENSIVE information on the web if you want to know more.

These commands work on my HTC Desire running Cyanogenmod 6 (Android 2.2), most, if not all of them should work on other devices and/or roms.

If you have any suggestions post them below or pm me and I will edit this post to include them.

Notes

Most of these commands require root privileges, type su first.

Everything after a # is a not and not a part of the command.

busybox

What it does

Provides a selection of commands not built into android by default.

Example(s)

busybox cp a b

Notes

busybox is included in most custom roms and has aliases set up so you do not need to type busybox before the commands eg, 'cp' is the same as 'busybox cp' in most custom roms.

cat

What it does

Prints the contents of a (text)file onscreen.

Example(s)

cat file

cd

What it does

Changes the current directory. You may find it easier to change to the directory you will be working in before issuing other commands so you dont need to include the full path in your commands.

Example(s)

cd .. # Go up 1 directory level, eg go from '/sdcard/download/ to '/sdcard'.

cd /sd-ext # Change to '/sd-ext'.

chmod

What it does

Makes a file executable

Example(s)

chmod 755 /data/bin/yourbin

cp

What it does

Copies files/directories

Example(s)

cp filea fileb

cp -rf directorya directoryb # Copy entire directory recursively and forces copy.

df

What it does

Displays information on all mounted filesystems (free space).

Example(s)

df -hm # Show disk usage in human readable format in Megabytes.

du

What it does

Diplays the size of files/directories.

Example(s)

du -md 1 # Prints the size of all directories in Megebytes.

du -sh file # Prints the size of file in human readable format.

du -sh directory # Prints the size of directory in human readable format.

export

What it does

Sets environment variables.

Example(s)

export PATH=$PATH;/sd-ext/bin;

free

What it does

Display the amount of free and used system memory

losetup

What it does

Associates loop disk images with loop devices.

Example(s)

losetup /sdcard/disk.img /dev/block/loop7

Notes

Android 2.2's implementation of apps2sd uses one loop device for each app saved to SD. There are 8 loop devives by default (loop0-loop7) so if you have 8 or more apps saved to SD you will not be able to use this command. There is no issue when using 'oldschool a2sd'

ls

What it does

List Directory contents.

Example(s)

ls -a # List directory contents including hidden contents.

mount

What it does

Mounts a filesystem.

Example(s)

mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 # Remounts /system as writable.

mount -o remount,ro -t yaffs2 /dev/block/mtdblock3 # Remounts /system as read only.

mount -t ext2 /dev/block/loop6 /sdcard/disk # Mount loop6 on /sdcard/disk.

mount /sd-ext /sdcard/sd-ext # Mount /sd-ext on /sdcard/sd-ext.

Notes

On other devices it may be possible to mount disk images without going through losetup and using the option -loop in mount instead.

If you are having trouble with mount try using busybox mount instead, the busybox version seems more capable than the one shipped with Android.

mv

What it does

Move/rename files/directories

Example(s)

mv download/file stuff/file

mv picture4.jpg mydog.jpg

ping

What it does

Pings a server to check for conectivity.

Example(s)

ping -c 5 http://www.google.com # Ping google 5 times

Notes

if you do not include the -c option ping will work indefinatly.

pwd

What it does

Prints the current directory.

rm

What it does

Remove file/directory.

Example(s)

rm file

rm -rf directory # Delete a directory and its contents.

rmdir

What it does

Removes a directory

Example(s)

rmdir emptydir

Notes

If a directory has contents us 'rm -rf' instad.

su

What it does

Gives you root privelages.

touch

What it does

Makes an empty file

Example(s)

touch file.txt

wget

What it does

Download things from http or ftp.

Example(s)

wget http://www.google.com