Home Linux Commandline Tools BusyBox: The Swiss Army Knife of Embedded Linux

BusyBox: The Swiss Army Knife of Embedded Linux

Busybox is described on its manual page as the swiss army knife of embedded Linux. It combines small versions of common UNIX utilities into a single small executable. It provides around 400 implementations of Linux commands such as more, less, head, tail, grep, awk, sed, dpkg, all compiled into a single binary.

This executable is small in size (below 1MB) and thus useful in situations whereby we are limited in terms of disk space e.g running an entire temporary operating system on a RAM disk, embedded systems, mobile devices, and such.

Busybox looks at the name by which it is called by and will act according to the desired program, for example if we call busybox through a symbolic link ls, it will perform an action resembling ls command similarly if we call it through the mkdir symbolic link, it performs actions similar to mkdir.

Installing BusyBox in Linux

On Linux, you can install BusyBox using your default package manager as shown.

$ sudo apt install busybox         [On Debian, Ubuntu and Mint]
$ sudo yum install busybox         [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux]
$ sudo emerge -a sys-apps/busybox  [On Gentoo Linux]
$ sudo pacman -S busybox           [On Arch Linux]
$ sudo zypper install busybox      [On OpenSUSE]  
$ sudo apk add busybox             [On  Alpine] 
$ docker run cmd.cat/busybox busybox  [On Docker]  

If your current Linux distribution is not mentioned here you can check out the link in the references section on how to install it.

How to Use BusyBox in Linux

To get started, execute the command busybox without any options or flags.

# busybox

The output is a list of all commands supported by the busybox along with other useful options.

Busybox Usage
Busybox Usage

To view the exact commands we can list them as follows:

# busybox --list
Busybox Commands
Busybox Commands

To view the file size of the binary we write.

# cd /usr/sbin/ && du -h busybox  
Check File Size of Busybox
Check File Size of Busybox

A much clearer picture is obtained when we compare a command’s options from the Linux shell and the busybox shell.

# grep --help          [Shell]
# busybox grep --help  [Busybox]
Compare Shell and Busybox
Compare Shell and Busybox

As you can see from the output of both executions some of the options from the Linux shell are not available in the output from busybox. In most cases, we will find that busybox options are all we need to perform specific tasks in common applications such as IoT devices.

To be able to use busybox commands, we write the commands preceded by the busybox keyword, for example, to search for a string using the grep command we write.

# busybox grep "SearchString" file.txt

The above command works similarly to the one in a Linux shell.

Alternatively, we can also access the busybox shell and avoid using the busybox keyword every time we need to execute commands as follows.

# busybox sh
Busybox Shell
Busybox Shell

While in the shell we can execute commands normally as if we were in a Linux shell.

# grep "SearchString" file.txt 

To exit the shell write.

# exit

Busybox is written with considerations for limited resources and size optimizations. Its modularity allows inclusion and exclusion of commands/features at compile-time, in that, we can include only components we need and therefore this makes it easy to customize its implementation in systems such as mobile, embedded, etc.

Generally speaking, we don’t need a busybox in our Linux systems since we already have the full package, as mentioned it is useful in cases whereby we have a limited amount of disk space to work with.

Ravi Saive
I am an Experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies. Founder of TecMint.com, LinuxShellTips.com, and Fossmint.com. Over 150+ million people visited my websites.

Each tutorial at UbuntuMint is created by a team of experienced writers so that it meets our high-quality standards.

Was this article helpful? Please add a comment to show your appreciation and support.

Got something to say? Join the discussion.

Thanks for choosing to leave a comment. Please keep in mind that all comments are moderated according to our comment policy, and your email address will NOT be published or shared. Please Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.