Join Date: Jan 2009
Terminal goodies -
09-29-2010, 04:40 PM
If you've ever played with the Android terminal (via ConnectBot or another app, or from your PC over USB cable using 'adb shell' commands) you might have found many traditional unix commands are missing/lacking, like 'du' for example to see how much space a given set of files or folders is consuming.
I'm used to unix environments where each command like 'ls' and 'du' tend to be executables so when I type at the shell prompts 'du' and get a 'permission denied' response I assumed I either truly didn't have permissions or that it doesn't exist.
What I didn't know before today is that there are some super-utility commands that combine a whole bunch of commands into one, and that's how it's working on our Streaks. There's also different flavours of them. By default, most of our commands come from one called 'toolbox' which is functional but brief (a quick ls -l on /system/bin will show that many commands, including ls, are in fact symbolic links to toolbox).
A bigger set of commands is available in something called 'busybox', and it's already on my Streak but under a slightly different name: /system/bin/busybox_1P8P1
Running this (you can alias it etc. too) shows we have the following toys available:
BusyBox v1.8.1 (2007-11-14 10:11:37 EST) multi-call binary
Copyright (C) 1998-2006 Erik Andersen, Rob Landley, and others.
Licensed under GPLv2. See source distribution for full notice.
Usage: busybox [function] [arguments]...
or: [function] [arguments]...
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable. Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as!
Currently defined functions:
[, [[, addgroup, adduser, adjtimex, ar, arp, arping, ash,
awk, basename, bunzip2, bzcat, bzip2, cal, cat, catv,
chattr, chgrp, chmod, chown, chpasswd, chpst, chroot,
chrt, chvt, cksum, clear, cmp, comm, cp, cpio, crond,
crontab, cryptpw, cut, date, dc, dd, deallocvt, delgroup,
deluser, df, dhcprelay, diff, dirname, dmesg, dnsd, dos2unix,
du, dumpkmap, dumpleases, echo, ed, egrep, eject, env,
envdir, envuidgid, ether-wake, expand, expr, fakeidentd,
false, fbset, fdflush, fdformat, fdisk, fgrep, find, fold,
free, freeramdisk, fsck, fsck.minix, ftpget, ftpput, fuser,
getopt, getty, grep, gunzip, gzip, halt, hdparm, head,
hexdump, hostid, hostname, httpd, hwclock, id, ifconfig,
ifdown, ifup, inetd, init, insmod, install, ip, ipaddr,
ipcalc, ipcrm, ipcs, iplink, iproute, iprule, iptunnel,
kbd_mode, kill, killall, killall5, klogd, last, length,
less, linux32, linux64, linuxrc, ln, loadfont, loadkmap,
logger, login, logname, logread, losetup, ls, lsattr,
lsmod, lzmacat, makedevs, md5sum, mdev, mesg, microcom,
mkdir, mkfifo, mkfs.minix, mknod, mkswap, mktemp, modprobe,
more, mount, mountpoint, mt, mv, nameif, nc, netstat,
nice, nmeter, nohup, nslookup, od, openvt, passwd, patch,
pgrep, pidof, ping, ping6, pipe_progress, pivot_root,
pkill, poweroff, printenv, printf, ps, pscan, pwd, raidautorun,
rdate, readlink, readprofile, realpath, reboot, renice,
reset, resize, rm, rmdir, rmmod, route, rpm, rpm2cpio,
run-parts, runlevel, runsv, runsvdir, rx, sed, seq, setarch,
setconsole, setkeycodes, setlogcons, setsid, setuidgid,
sh, sha1sum, slattach, sleep, softlimit, sort, split,
start-stop-daemon, stat, strings, stty, su, sulogin, sum,
sv, svlogd, swapoff, swapon, switch_root, sync, sysctl,
syslogd, tail, tar, taskset, tcpsvd, tee, telnet, telnetd,
test, tftp, time, top, touch, tr, traceroute, true, tty,
ttysize, udhcpc, udhcpd, udpsvd, umount, uname, uncompress,
unexpand, uniq, unix2dos, unlzma, unzip, uptime, usleep,
uudecode, uuencode, vconfig, vi, vlock, watch, watchdog,
wc, wget, which, who, whoami, xargs, yes, zcat, zcip
May be old hat for the unix/android pros, but a new and useful find for me so thought I'd share it. This is on my "O2" released 2.1, so not sure if it'll have exactly the same name or presence on other builds.
Yay for *grep, sort, vi, and many others.
---------- Post added at 05:40 PM ---------- Previous post was at 05:30 PM ----------
Ugg.. and either I've been half-asleep, or I have root access using the O2 build of 2.1 without installing any software / flashing / etc.
I could swear it wouldn't previously work?
$ fm_hcitool 1
Running test 1
Send failed: Operation not permitted
$ su -root
# fm_hcitool 1
Running test 1
Turn on FM power Done
Turn on audio path Done
switching to FM
Sleeping for 1 sec...
rx device = 34137363
rx device = 34137363, done
tx device = 0