ETOOBUSY 🚀 minimal blogging for the impatient
Busybox - multipurpose executable
Busybox is a multi-purpose binary, i.e. a single binary that is capable of doing a lot of things. This is the description that can be found in the website:
BusyBox combines tiny versions of many common UNIX utilities into a single small executable. It provides replacements for most of the utilities you usually find in GNU fileutils, shellutils, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU cousins; however, the options that are included provide the expected functionality and behave very much like their GNU counterparts. BusyBox provides a fairly complete environment for any small or embedded system.
As of this writing, it is capable of providing most functionalities of at least the following programs:
which probably makes it the item you want in a #toolbox.
Using busybox
There are several ways to invoke the tools that are contained in
Busybox. The most basic one is to provide the command and its
parameters as comand-line parameters to busybox
itself, e.g. the
following example does what you would expect:
If you plan on using the tools interactively many times, typing
busybox
over and over can be annoying, so you have two options. The
least invasive is to enter the shell provided by busybox
, which is no
bash but it’s honest. From there, all tools are just available by
magic:
If you don’t like Busybox’s shell (e.g. because you have a different
one, or want to invoke commands from somewhere else) then it’s possible
to install the sub-commands as symbolic links to the busybox
executable itself. In fact, when it’s run with a different name,
busybox
becomes the program with that name. If this is your way,
option --install
will be helpful.
Why busybox
In The #toolbox?
You might wonder why you would ever want to include Busybox in your #toolbox, provided that it includes pretty basic tools.
One consideration is that some of those tools are above basic level
and might lack in a typical Linux installation. Two notable examples are
ncat (as nc
) and xxd, the former useful to set up quick TCP
connections towards a destination (and check if it’s alive, how it
works, etc.), the former to get a better idea of the contents of a
(binary) file.
The shell itself, along with the “usual” Linux tooling, can come very handy anyway. As an example, you might run into a very stripped down Docker image where there is a single “business logic” executable only, and all tools are lacking; in this case, injecting Busybox in the container’s filesystem is an invaluable help for troubleshooting.
Last, but not least, Busybox is indeed also released as a statically compiled executable, just look at the binaries directory.