Skip to main content
Explain

What is BusyBox in Linux? How to Use it?

Learn why BusyBox has suddenly gained a following among certain Linux users.

Abhishek Prakash

Warp Terminal

BusyBox is getting popular these days, specially among Docker users. Many Docker images use BusyBox to provide you with a minimal image.

And this could leave many users confused specially if you take Linux commands for granted. You think ls, mv and other such commands are part of Linux, while the truth is that these commands are part of GNU Coreutils package and most Linux distributions have it preinstalled.

GNU Coreutils is almost the de facto provider of various UNIX/Linux commands. Almost because there are always alternatives and BusyBox is one such alternative to GNU Coreutils.

What is BusyBox?

BusyBox is an open source project that provides a stripped down implementation of around 400 common UNIX/Linux commands. Stripped down? Yes. BusyBox implementation removes the uncommon, rarely used command options. Everything fits under 1 MB and this minimal image is the reason why it has gained popularity among embedded system and IoT domain as well as in the cloud computing world.

Don't go by its size. BusyBox has scope for sed and awk like classic editors (stripped down version again) and it contains its own shell too. It even contains an init command which can be launched as PID 1. This means that BusyBox can be configured as an alternative to Systemd, OpenRC etc.

BusyBox is superb alternative to GNU Coreutils specially in cases where the small size of the operating system matters big.

🗒️
BusyBox gives you popular Linux commands like mv, mkdir, ls etc but it contains only the common used options of these commands. This minimalism is the USP of BusyBox.

Is it a problem that you don't get the full Linux command options with BusyBox?

That's depend on your need, really. Most people will never need all the options of a command. Some Linux commands have more than 50 options and I bet you never used all the options of even a single Linux command.

BusyBox cuts down on the rarely used options. For example, the ls command has option G which removes the group name from the long list output (ls -l).

Now, I think you never needed this option. This is why it is not present in the ls implementation of BusyBox. If you really need an output where the group name is not included, all you have to do is to use the cut or awk command for that purpose.

Take another example. This is the help page of the mv command from GNU Coreutils:

Usage: mv [OPTION]... [-T] SOURCE DEST
  or:  mv [OPTION]... SOURCE... DIRECTORY
  or:  mv [OPTION]... -t DIRECTORY SOURCE...
Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY.

Mandatory arguments to long options are mandatory for short options too.
      --backup[=CONTROL]       make a backup of each existing destination file
  -b                           like --backup but does not accept an argument
  -f, --force                  do not prompt before overwriting
  -i, --interactive            prompt before overwrite
  -n, --no-clobber             do not overwrite an existing file
If you specify more than one of -i, -f, -n, only the final one takes effect.
      --strip-trailing-slashes  remove any trailing slashes from each SOURCE
                                 argument
  -S, --suffix=SUFFIX          override the usual backup suffix
  -t, --target-directory=DIRECTORY  move all SOURCE arguments into DIRECTORY
  -T, --no-target-directory    treat DEST as a normal file
  -u, --update                 move only when the SOURCE file is newer
                                 than the destination file or when the
                                 destination file is missing
  -v, --verbose                explain what is being done
  -Z, --context                set SELinux security context of destination
                                 file to default type
      --help     display this help and exit
      --version  output version information and exit

Now, here is the mv command help page from BusyBox:

Usage: mv [-fin] SOURCE DEST
or: mv [-fin] SOURCE... DIRECTORY

Rename SOURCE to DEST, or move SOURCE(s) to DIRECTORY

	-f	Don't prompt before overwriting
	-i	Interactive, prompt before overwrite
	-n	Don't overwrite an existing file

See the difference?

How to get BusyBox?

There are various ways you get BusyBox.

If you simply want to experience BusyBox on your current Linux distribution, you can install it using your distribution's package manager like Apt or DNF or Yum.

On Ubuntu, you can use this command to install BusyBox:

sudo apt install busybox

After that, if you want to run the BusyBox version of a command, you have to add busybox before it.

busybox cat sample.txt

If a command is not implemented by BusyBox, it throws an error that 'applet not found'.

abhishek@LHB:~$ busybox xyz
xyz: applet not found

Alternatively, you can download the Docker image of BusyBox and experience it in a running container.

Please make sure that you have Docker installed. Pull the official docker image:

docker pull busybox

Run a container from the image and enter the BusyBox shell:

docker run -it --rm busybox

Every Linux command you run here comes from BusyBox. You don't need to specify it explicitly.

BusyBox in docker container

Altogether, you don't need BusyBox on a regular Linux system. You already have full version of the Linux commands from GNU Coreutils there. There is no need to install a stripped down version.

But BusyBox has its usage in special areas like when you are configuring a minimal Linux OS for embedded or IoT device. The same goes when you want to keep the size of your Docker image small.

I hope you have a better understanding of BusyBox. If you need any clarification or have a suggestion, please let me know in the comments.

Abhishek Prakash