X
Popular Searches

What Is BusyBox and Where Is It Used?

Graphic illustration of a laptop showing a terminal on its screen
fatmawati achmad zaenuri/Shutterstock.com

BusyBox is a collection of core Unix utilities packaged as a single binary. This makes it ideal for resource-constrained environments such as embedded devices. The complete distribution has almost 400 of the most common commands.

BusyBox is open-source and licensed under the GPL. It was created in 1995 with the intention of making a bootable system fit onto a single floppy. Bundling commands together into one binary reduces overheads and permits code-sharing between seemingly independent applications.

What Does BusyBox Include?

BusyBox provides the everyday convenience commands that often feel like they’re part of your shell. Although userland tools like ls and cat are ubiquitous, they actually reside in a separate utility package that’s independent of your shell. Many Linux distributions deliver these commands via GNU’s coreutils but others ship BusyBox instead.

The project works by symlinking familiar command names in /usr/bin to the BusyBox binary. This executable then invokes the function corresponding to the name passed as its first argument.

  • With BusyBox the command mkdir runs /usr/bin/busybox mkdir
  • With GNU Coreutils – the command mkdir runs /usr/bin/mkdir.

You can transparently use commands like mkdir, passwd, ps, tar, and wget once BusyBox is installed. Commands are implemented as “applets” which are combined into a functioning BusyBox distribution. The full set weighs in at about 1MB. Applets are removable so the binary size can be shrunk even further. You can check what’s available in your installation by running busybox with no arguments.

Advertisement

As BusyBox was created to power tiny bootable systems, it covers everything needed in userland to start and administrate a POSIX system. That extends to a minimal init implementation that’s capable of running as process ID 1 and supporting system services. You could adopt BusyBox as a lightweight alternative to a regular init or systemd daemon.

As BusyBox is intentionally minimal, not every command implements all the features of its GNU counterpart. You might find some missing flags or behavioral differences in uncommon situations. This is one of the trade-offs of BusyBox’s streamlined nature.

Where Is BusyBox Used?

BusyBox can be found wherever disk usage is a concern. It’s used by minimal operating systems such as Alpine as well as specialized scenarios like embedded devices and mobile shells.

Chances are good that a Unix-derived device that’s not running a conventional OS distribution will be using BusyBox. You’ll find it on your network router, smart TV, modern car, and IoT devices. Each of these settings is characterized by a need to run core userland tools within a heavily resource-constrained environment.

Shipping a single all-in-one binary is more efficient. It reduces redundancy by allowing all the commands to share common code without storing standalone libraries on disk. As BusyBox offers good compatibility with other implementations, and is licensed under the GPL, it’s usually the go-to option for environments needing a lightweight set of utilities.

Vendors of embedded devices also benefit from BusyBox’s modular nature. An IoT product may only need a handful of critical utilities to provide its functionality. Distributing a modified BusyBox binary frees up a few more KBs of disk space which can be a significant saving.

How to Try BusyBox

You can install BusyBox without replacing your current utilities. Use your package manager to add busybox, then append your chosen command to the busybox binary to run an applet:

busybox mkdir test
Advertisement

This ensures the BusyBox version of the command will be used instead of the version in your shell’s default path.

Another way to try BusyBox is via its official Docker image:

docker run -it --rm busybox

If you’ve got Docker installed, this will drop you into BusyBox’s shell implementation. You can run a specific command by adding it after the image name:

docker run -it --rm busybox mkdir demo

BusyBox also has a JavaScript emulator that lets you try the utilities in your web browser.

On most Linux distributions you can’t completely replace coreutils with BusyBox. Distro-specific commands and packages are often hardwired to expect the coreutils utilities to be available. Your distribution will usually refuse to uninstall this package as it could render the system inoperable if init is removed.

Advertisement

If you want to rely on BusyBox, it’s best to start with a distribution that uses it and then layer your other software on top. Adding BusyBox alongside coreutils as shown above works well when you need to check how an applet will respond in a particular scenario.

Conclusion

BusyBox is a lightweight implementation of userland UNIX utilities that comes packaged as a single binary. You can combine it with a Linux kernel to create a functioning system with no other dependencies.

BusyBox is optimized for space-constrained environments. This makes it ideal for embedded products such as IoT devices. You may also find BusyBox installed on minimal but otherwise general purpose Linux distributions such as Alpine Linux.

Whether you’re using BusyBox or GNU Coreutils, your familiar commands will generally “just work” with either implementation. Any issues which do arise will usually be due to BusyBox not implementing a certain rare flag or config option.

James Walker James Walker
James Walker is a CloudSavvy IT contributor. He's the Founder of Heron Web where he provides bespoke software development services to SMEs, specializing in web applications and APIs. He's experienced with the complete development lifecycle and works with DevOps technologies such as GitLab, Docker, and Kubernetes. Read Full Bio »

The above article may contain affiliate links, which help support CloudSavvy IT.