BusyBox: The developer’s ‘Swiss Army Knife for Embedded Linux’

Sandeep Kumar
5 min readSep 23, 2022

Introduction

When we do investigation on Unix/Linux based systems we may need various tools and utilities like ‘wget’ to make HTTP call, gzip, unzip, sed etc. In this scenario, an OS is required with these utilities, but it is heavy weight and complete OS may not be available due to environment constraint like application running in Kubernetes with Distroless images.

To make available required utilities in such restricted environment, we can use Busybox which is a single executable for several utilities. It makes developers life easy in may situation where different utilities are required.

About BusyBox

BusyBox is a software suit which provides various common Unix utilities as single executable. The utilities are kept lightweight compare to their full version. It has been designed specially to make BusyBox light weight and to provide complete environment of small/embedded systems.

It has been licensed under GPLv2 means you can use it freely and distribute with source. it has been designed modular to make it easy to include or exclude commands at compile time. So you can checkout it’s source and compile and build own BusyBox with selected/excluded components.

BusyBox provides single executable for around 300 common commands therefore the developer has dubbed it “The Swiss Army Knife of Embedded Linux” reason “Swiss Army Knife” is known for many utilities in single knife.

BusyBox is available for many Unix based systems and there are may product using it. Some of them are: buildroot, OpenWrt, Zdisk, Mindi etc. It is also available as docker image which can easily be run into docker environment by using below command:

docker run -it --rm busyboxNote: It will open shell where you can run commands 

It has also other image variants like:busybox:uclib uclib via Buildroot, busybox:glibc glibc from Debian and busybox:musl musl from alpine.

It is also available with Bellard.org’s JsLinux which is used to boot Linux by using Javascript for browser. One can open webpage and use the utility commands from web browser.

BusyBox is also available for Windows, one can download Busybox from frippery.org and use it on Windows machine. Place the executable into Path and run it like:

You can run sh on Busybox and then run commands like:

BusyBox is also available for Ubuntu. You can install it by running below command:

sudo apt install busybox -y

Once installed, run Busybox:

Busybox can run on Kubernetes as well. Just need to run below command:

kubectl run -n default -i --tty busybox --image=busybox:latest -- /bin/sh

Similarly, BusyBox is available for several platform including Android and other Unix based embedded systems.

It is just magic box for developers who are investigating systems for different reasons for finding bugs, inspecting network communication and there may be many more reasons.

Below are list of commands typically available with BusyBox:

[, [[, acpid, adjtimex, ar, arch, arp, arping, ash, awk, basename, bc, blkdiscard, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, chgrp, chmod, chown, chpasswd,
chroot, chvt, clear, cmp, cp, cpio, cttyhack, cut, date, dc, dd, deallocvt, depmod, devmem, df, diff, dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap,
dumpleases, echo, egrep, env, expand, expr, factor, fallocate, false, fatattr, fgrep, find, fold, free, freeramdisk, fsfreeze, fstrim, ftpget, ftpput, getopt, getty,
grep, groups, gunzip, gzip, halt, head, hexdump, hostid, hostname, httpd, hwclock, i2cdetect, i2cdump, i2cget, i2cset, id, ifconfig, ifdown, ifup, init, insmod,
ionice, ip, ipcalc, ipneigh, kill, killall, klogd, last, less, link, linux32, linux64, linuxrc, ln, loadfont, loadkmap, logger, login, logname, logread, losetup, ls,
lsmod, lsscsi, lzcat, lzma, lzop, md5sum, mdev, microcom, mkdir, mkdosfs, mke2fs, mkfifo, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mt, mv,
nameif, nc, netstat, nl, nologin, nproc, nsenter, nslookup, nuke, od, openvt, partprobe, paste, patch, pidof, ping, ping6, pivot_root, poweroff, printf, ps, pwd,
rdate, readlink, realpath, reboot, renice, reset, resume, rev, rm, rmdir, rmmod, route, rpm, rpm2cpio, run-init, run-parts, sed, seq, setkeycodes, setpriv, setsid, sh,
sha1sum, sha256sum, sha512sum, shred, shuf, sleep, sort, ssl_client, start-stop-daemon, stat, strings, stty, svc, svok, swapoff, swapon, switch_root, sync, sysctl,
syslogd, tac, tail, tar, taskset, tee, telnet, test, tftp, time, timeout, top, touch, tr, traceroute, traceroute6, true, truncate, tty, ubirename, udhcpc, udhcpd,
uevent, umount, uname, uncompress, unexpand, uniq, unix2dos, unlink, unlzma, unshare, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, w, watch, watchdog,
wc, wget, which, who, whoami, xargs, xxd, xz, xzcat, yes, zcat

Use Case

To demonstrate Busybox, let’s install BusyBox on Ubuntu:

Use below command to install BusyBox on Ubuntu:

sudo apt install busybox -yThen run below command:busybox sh

Download Busybox executable from Link and set path from environment variable or run below command on cmd:

set path=%path%;<absolute path of directory where busybox.exe placed>Let's placed busybox.exe in c:\busybox then, open cmd and run below line:set path=%path%;c:\busybox
Then run below command:
c:/> busybox sh

Run below command to run Busybox on docker:

docker pull busybox:latestdocker run -it --rm busybox 

Run below command to run Busybox on Kubernetes:

kubectl run -n default -i --tty busybox --image=busybox:latest -- /bin/sh

Once Busybox opened command prompt like:

Run utility commands like:

Conclusion

Busybox is very useful suit of utilities which can be used to various Unix based systems. It is a single component which allows you to perform various utility commands. It is very useful especially in when developers are investigating the environment while find bug causes in those cases where no full-OS versions are available like distroless image has been used for running processes.

Since it provides several utility commands as single executable, it has been dubbed as “Swiss Army Knife for Embedded Linux” by its developer. It is too useful and thus embedded with various Linux distributions.

References

--

--

Sandeep Kumar

Sandeep Kumar holds Master of Computer Application, working as Technical Architect having 11+ years of working experience in banking, retail, education domains.