BusyBox is considered the “Swiss Army Knife” of embedded Linux systems due to its minimalistic and portable size. Due to its decent functionalities and size, you can use it in mobile devices, distro installers, and portable ram-based OSes.
This minimalist setup is possible because all of its commands or “applets” are compiled in a single binary located at
/bin. Its applets share functionalities, which reduces the duplication in its source code and compiled versions. Developers who make embedded systems use BusyBox to embed the lite version of UNIX tools.
Embedded systems need to optimize processes and even utilities to maximize limited computing power. BusyBox is probably one of the best implementations of this minimalist concept. It lets the users install common UNIX tools to put functionalities in a resource-limited system.
Here’s how you can install its utilities in Debian and Rhel-based distros or through a Docker container.
What is BusyBox in Linux?
It is a single executable that contains a stripped-down version of common GNU utilities.
Whenever you need Linux utilities in a system with scarce disk space and power, BusyBox is one of the best options for you. For comparison, the tarball for a full BusyBox source code is at about 2.4MB. A single autoconf package is about 600 KB, and that’s only for the compiled binary of one utility.
Instaling BusyBox in Linux
There are three ways to install and use BusyBox on a Linux environment. It is available via repositories for both Debian and RHEL-based distros. Installing BusyBox is the same as installing any other packages within the Terminal.
$ sudo apt install busybox
$ sudo dnf install busybox
The installation process is usually seamless and fast because BusyBox inherently has a small archive and compile size.
Another version of BusyBox is called the BusyBox Static, which is primarily used for rescuing systems. It is a standalone package that can load shell utilities, which can help you repair your system if you know what you’re doing. Install the static version by deploying the code below:
$ sudo apt install update
$ sudo apt install busybox-static
Installing BusyBox via Docker
You can also use BusyBox via Docker by pulling and running the image. First, you need to install docker in your system. You can pull the BusyBox image when things are properly installed by running the code below. This will automatically pull the latest BusyBox version available within the Docker repository.
$ sudo docker pull busybox
Execute the command below to check if BusyBox is installed correctly. As shown in the screenshot, the BusyBox image is quite small with only 1.24MB.
$ sudo docker images
You can also install BusyBox on Android devices through the Android goldfish software. But this is another guide for another day.
How to Use BusyBox?
Once you have finally installed BusyBox with your preferred option, you can now use its utilities by typing the command “busybox” and the corresponding applet. For example, if you want to use the
echo applet that comes in-built within the system, just add the “busybox” prompt and follow it with your
This also works on any command as long as they are included in your BusyBox installation. You can check what commands are available by simply typing “busybox” in the prompt. Or you can also check the info on the BoxMatrix wiki if you want to know other information such as description, firmware software, and installation path.
Take note: These applets are extremely stripped-down versions of GNU utilities. A fully-functional GNU utility might only be available with half of its options in the BusyBox version.
$ busybox <command>
Use this code below to run BusyBox shell via Docker. This command will automatically create an interactive bash shell in a container because of the “
-t” flag. In addition, the “
--rm” flag will automatically remove the container when it exits.
$ sudo docker run -it --rm busybox
Another way to run BusyBox within a shell is by executing the command below, which works like a charm if you install your version via
apt or the source code. This prompt will give you a shell-like environment that you can use, just like the
bash. It’s a better option if you need to use a lot of commands and not just a one-time prompt.
$ busybox sh
How to Configure BusyBox?
In the following paragraphs, you can also install BusyBox with different configurations by installing your own binary. The source code is a popular option for people who wants to add and remove applets.
Download the Source Code
If you want to configure your installation, you need to install BusyBox via the official source code. But first, you need to install the
ncurses library, which optimizes character display and functionalities in the terminal.
$ sudo apt-get install libncurses5-dev
Next, you must access the
menuconfig to configure which utilities would be included or removed. All utilities are categorized based on their usage, so select the intended category and press “Enter”.
$ make menuconfig
If you want to remove the diff command in the installation, you need to select it in the dialogue and press “N.” The asterisk beside it will disappear, which indicates that it will not be included in the binary. Press “Y” if you want to include additional features instead.
Press the “Exit” button until a prompt appears, which allows you to save your custom configuration. Select the “Yes” option to change your configuration, and after that, you will be back to the Terminal.
Before installing the BusyBox binary completely, you need to compile it. Execute the following codes below so you can compile the source code.
$ sudo apt-get install gcc g++ make build-essential
$ sudo apt-get install ia32-libs ia32-libs-multiarch
The make command executes the options determined by your compile configurations. Execute the following prompts to compile your configured BusyBox.
$ make defconfig
$ file busybox
$ ldd busybox
And now you’re ready to use BusyBox on your Linux system. Installations from official repositories are still the best option for convenience and standardization. But it’s nice to know that you can further strim down your options when needed.
If this guide helped you, please share it. ?