BusyBox: The Swiss Army Knife of Embedded Linux

Toolbox

An Android device or emulator comes with a meager set of 71 command line tools. Each one is a symbolic link to the executable file /system/bin/toolbox.

adb shell
echo $PATH
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin

cd /system/bin
pwd
/system/bin

ls -l toolbox
-rwxr-xr-x root     shell      267176 2014-11-14 05:59 toolbox

ls -l | grep ' -> toolbox' | more
lrwxr-xr-x root     shell             2014-11-14 06:00 cat -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 chcon -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 chmod -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 chown -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 clear -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 cmp -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 cp -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 date -> toolbox
lrwxr-xr-x root     shell             2014-11-14 06:00 dd -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 df -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 dmesg -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 du -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 getenforce -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 getevent -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 getprop -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 getsebool -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 grep -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 hd -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 id -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 ifconfig -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 iftop -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 insmod -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 ioctl -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 ionice -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 kill -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 ln -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 load_policy -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 log -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 ls -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 lsmod -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 lsof -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 md5 -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 mkdir -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 mkswap -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 mount -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 mv -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 nandread -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 netstat -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 newfs_msdos -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 notify -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 printenv -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 ps -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 r -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 readlink -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 renice -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 restorecon -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 rm -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 rmdir -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 rmmod -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 route -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 runcon -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 schedtop -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 sendevent -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 setconsole -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 setenforce -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 setprop -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 setsebool -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 sleep -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 smd -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 start -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 stop -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 swapoff -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 swapon -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 sync -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 top -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 touch -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 umount -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 uptime -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 vmstat -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 watchprops -> toolbox
lrwxr-xr-x root     shell             2014-11-14 05:59 wipe -> toolbox

toolbox
Toolbox!

toolbox date -u
Sun Jul 26 15:50:38 GMT 2015

date -u
Sun Jul 26 15:50:40 GMT 2015

exit

Busybox

Busybox is a better set of 219 command line tools, including Unix classics such as awk, find, and sed. It’s already installed on the Samsug Galaxy S5 emulator in Genymotion. Each tool is a symbolic link to the executable file /system/xbin/busybox. The S5 has one link (length) with no corresponding tool; and five tools (mkdosfs, nbd-client, nc, pipe_progress, reboot) have no link.

adb shell
cd /system/xbin
pwd
/system/xbin

ls -l busybox
-rwxr-xr-x root     shell     1218127 2014-11-14 05:54 busybox

ls -l | grep ' -> toolbox' | more
lrwxr-xr-x root     shell             2014-11-14 05:59 [ -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 [[ -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 arp -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ash -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 awk -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 base64 -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 basename -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 bbconfig -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 blockdev -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 brctl -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 bunzip2 -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 bzcat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 bzip2 -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 cal -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 cat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 catv -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 chattr -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 chgrp -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 chmod -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 chown -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 chroot -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 chvt -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 clear -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 cmp -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 comm -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 cp -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 cpio -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 crond -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 crontab -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 cut -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 date -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 dc -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 dd -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 deallocvt -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 depmod -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 devmem -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 df -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 diff -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 dirname -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 dmesg -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 dnsd -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 dos2unix -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 du -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 echo -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ed -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 egrep -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 env -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 expand -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 expr -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 false -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 fdisk -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 fgrep -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 find -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 findfs -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 flash_lock -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 flash_unlock -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 flashcp -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 flock -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 fold -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 free -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 freeramdisk -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 fsync -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ftpget -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ftpput -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 fuser -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 getopt -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 grep -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 groups -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 gunzip -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 gzip -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 halt -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 head -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 hexdump -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 id -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ifconfig -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 insmod -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 install -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 iostat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ip -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 kill -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 killall -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 killall5 -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 length -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 less -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ln -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 losetup -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ls -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lsattr -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lsmod -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lspci -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lsusb -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lzcat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lzma -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lzop -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 lzopcat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 man -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 md5sum -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mdev -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mesg -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mkdir -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mke2fs -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mkfifo -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mkfs.ext2 -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mkfs.vfat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mknod -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mkswap -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mktemp -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 modinfo -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 modprobe -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 more -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mount -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mountpoint -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mpstat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 mv -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 nanddump -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 nandwrite -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 netstat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 nice -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 nohup -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 nslookup -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ntpd -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 od -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 openvt -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 patch -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 pgrep -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 pidof -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ping -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 pkill -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 pmap -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 poweroff -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 printenv -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 printf -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ps -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 pstree -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 pwd -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 pwdx -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 rdev -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 readlink -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 realpath -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 renice -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 reset -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 resize -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 rev -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 rm -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 rmdir -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 rmmod -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 route -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 run-parts -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 rx -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sed -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 seq -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 setconsole -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 setkeycodes -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 setserial -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 setsid -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sh -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sha1sum -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sha256sum -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sha512sum -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sleep -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sort -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 split -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 stat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 strings -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 stty -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sum -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 swapoff -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 swapon -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 switch_root -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sync -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 sysctl -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tac -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tail -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tar -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tee -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 telnet -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 telnetd -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 test -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tftp -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tftpd -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 time -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 timeout -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 top -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 touch -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tr -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 traceroute -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 true -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tty -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 ttysize -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 tune2fs -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 umount -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 uname -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 uncompress -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 unexpand -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 uniq -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 unix2dos -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 unlzma -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 unlzop -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 unxz -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 unzip -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 uptime -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 usleep -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 uudecode -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 uuencode -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 vi -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 watch -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 wc -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 wget -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 which -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 whoami -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 xargs -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 xz -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 xzcat -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 yes -> busybox
lrwxr-xr-x root     shell             2014-11-14 05:59 zcat -> busybox

busybox --list
[
[[
arp
ash
awk
etc.

busybox --list | wc -l
219

busybox awk --help
BusyBox v1.19.4-cm9 bionic (2012-02-05 18:40 +0100) multi-call binary.

Usage: awk [OPTIONS] [AWK_PROGRAM] [FILE]...

	-v VAR=VAL	Set variable
	-F SEP		Use SEP as field separator
	-f FILE		Read program from FILE

Install Busybox on the Android Nexus 5 emulator

Download a prebuilt binary of Busybox onto your Mac or PC Desktop, for example busybox-arm7l (seven lowercase L). The executable file busybox is in the directory /system/xbin on the Genymotion S5 emulator, so I would like to install it into the same directory on the Android Nexus 5 emulator (emulator-5554). This directory is in a filesystem that is mounted read-only; we will have to remount it as read-write.

cd ~/Desktop
pwd
/Users/myname/Desktop

ls -l busybox-arm7l
-rw-r-----@ 1 myname  mygroup  1109128 Jul 28 16:54 busybox-armv7l
od -c busybox-arm7l | head -1

adb -s emulator-5554 push busybox-armv7l /system/xbin/busybox
failed to copy 'busybox-armv7l' to '/system/xbin/busybox': Read-only file system

adb -s emulator-5554 shell

mount | grep /system
/dev/block/mtdblock0 /system ext4 ro,seclabel,relatime,data=ordered 0 0

ls -l /dev/block/mtdblock0
brw------- root     root      31,   0 2015-07-28 16:50 mtdblock0

mount -o rw,remount -t yaffs2 /dev/block/mtdblock0 /system

mount | grep /system
/dev/block/mtdblock0 /system ext4 rw,seclabel,relatime,data=ordered 0 0

exit

adb -s emulator-5554 push busybox-armv7l /system/xbin/busybox
2385 KB/s (1109128 bytes in 0.454s)

adb -s emulator-5554 shell

cd /system/xbin
pwd
/system/xbin

chmod 555 busybox
ls -l busybox
-r-xr-xr-x root     shell     1109128 2015-07-28 17:45 busybox

BusyBox is a set of Unix utilities (command line programs) that you can install into the Android Emulator to supplement the meager set that comes with the Emulator. Complete list of approximately 346 utilities.

Download busybox to the Android emulator

Download a prebuilt binary of BusyBox onto the desktop of your Mac or PC. The binary file busybox-armv4tl worked for Android Emulators running on Macintosh and PC. When we push this file into the Emulator, we will rename it busybox.

I would have liked to put busybox in one of the directories in my PATH on the Emulator.

# echo $PATH
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
But the directories /vendor/bin and /system/sbin does not exist, and the other directories are read-only. We will create a new directory named /data/busybox.

cd
cd Desktop
adb shell mkdir /data/busybox
adb shell ls -ld /data/busybox
adb push busybox-armv4tl /data/busybox/busybox
2643 KB/s (1096224 bytes in 0.404s)
adb shell ls -l /data/busybox/busybox
-rw-rw-rw- root     root      1096224 2013-05-20 18:33 busybox

Make the busybox file executable

Turn on the set-uid bit, too.

adb shell
# cd /data/busybox
# pwd
# ls -l busybox
-rw-rw-rw- root     root      1096224 2013-05-20 18:33 busybox
# chmod 4755 busybox
# ls -l busybox		(the mode bits should now be changed to rwsr-xr-x)
-rwsr-xr-x root     root      1096224 2013-05-20 18:33 busybox

Create a subdirectory to hold the symbolic links

A symbolic link in Unix is like an alias on a Mac or a shortcut on a PC. We will create 346 symbolic links to the busybox file and place them in a new directory named bbdir.

# cd /data/busybox   (You’re already there.)
# pwd
# mkdir bbdir
# ls -ld bbdir

Add two directories to your PATH

Is there a way to set the PATH in an ash start-up file such as .profile?

# echo $PATH
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin
# export PATH=$PATH:/data/busybox:/data/busybox/bbdir
# echo $PATH
/sbin:/vendor/bin:/system/sbin:/system/bin:/system/xbin:/data/busybox:/data/busybox/bbdir

Create the symbolic links

The symbolic links will let us avoid having to write the word busybox in front of each command. Be sure to type `back quotes`.

# cd /data/busybox
# for i in `busybox --list`
> do
> 	ln -s /data/busybox/busybox bbdir/$i
> done
# cd /data/busybox/bbdir
# ls -l
# ls -l | more

Play with BusyBox

# busybox --help
# busybox --help find

The purpose of the symbolic links is to allow us to say

# find / -name busybox -type f -print
/data/busybox/busybox
instead of
# busybox find / -name busybox -type f -print
# ls -l `find / -name busybox -type f -print`
-rwsr-xr-x root     root      1075144 2011-07-19 18:47 busybox
# exit

Things to try

  1. Do you have permission to install BusyBox on your phone?