BusyBox: A Swiss Army Knife for Linux
BusyBox is most useful on a system without a set of regular Linux utility programs, but you'll probably be exploring it on a standard Linux system. Because of this, you should use the PREFIX variable when installing BusyBox. The installation process creates symbolic links for all the utilities that BusyBox supports. This allows you to enter ls instead of busybox ls. Suppose you had begun working with BusyBox in the /tmp directory (such that a directory called /tmp/busybox-0.45 was created by the tar command). Then, if you want to create symbolic links in the same area, use this command:
make PREFIX=/tmp/busybox-0.45 install
The /tmp/busybox-0.45 directory will then contain subdirectories named bin, sbin and usr, each with symbolic links to /bin/busybox. You'll also need to copy the busybox binary to /bin before using these symbolic links:
cp /tmp/busybox-0.45/busybox /binNow you're ready to explore the symbolic links in your BusyBox subdirectories. For example, change to the bin directory:
cd /tmp/busybox-0.45/binThen use the ls symbolic link with the --help option:
./ls --helpYou see the same help text as indicated previously. This shows you that BusyBox is being used instead of the standard ls command on your Linux system.
BusyBox uses the GNU C library, or glibc, which can add substantially to the space requirements of an embedded system or boot disk. You might consider looking at alternate C libraries to save space. Examples include minix libc and newlibc. Another example that looks promising but doesn't yet support the full functionality of BusyBox is the uC-libc project from Rt-Control (see http://www.uclinux.org/). The maintainer of BusyBox, Erik Andersen, is currently working to enhance this mini C library so that it can be used to reduce the total size requirements for BusyBox.
The description of BusyBox so far is straightforward, but doesn't capture all that the program offers. Returning to the source code you un-tarred when you compiled BusyBox, load the file busybox.def.h into a text editor:
cd /tmp/busybox-0.45 vi busybox.def.h
The first part of this file (about the first 100 lines) contains #define statements for each utility capability that will be included in BusyBox. If you don't want to include the capabilities of one of these utilities, simply comment out that line. For example, if you don't need sed in the system you are using BusyBox on, comment out the line for sed using two forward slashes, like this:
//#define BB_SEDCommenting out a few of the larger utilities greatly reduces the size of the final busybox binary. For example, removing five complex programs (init, tar, sfdisk, gzip and gunzip) reduces the size of the busybox binary from 260KB to 155KB.
The second part of the busybox.def.h file (after a few explanatory comments) contains #define statements that activate or disable various features of BusyBox. Some of these features are intended to save memory, such as eliminating the use of the /proc file system, reducing the amount of on-line help provided and eliminating the use of regular expressions. Other #defines are specific to features of a single command. For example, you can eliminate the ability to create new tar files with the tar features of BusyBox. Unless you really need to shave off a couple more KB in the size of BusyBox, you shouldn't need to alter the #define options in the second section of the busybox.def.h file.
Embedded versions of Linux such as Lineo's Embedix may be the most obvious use of BusyBox, but you might come up with many other uses. For example, if you need to create an initrd file to boot up a system with unusual hardware, you can use BusyBox functionality to add the basic system utilities with a single easy-to-manage binary. Or, you might use BusyBox as part of a boot diskette or single-disk version of Linux, as the Linux Router Project and the Debian boot floppies.
Fast/Flexible Linux OS Recovery
On Demand Now
In this live one-hour webinar, learn how to enhance your existing backup strategies for complete disaster recovery preparedness using Storix System Backup Administrator (SBAdmin), a highly flexible full-system recovery solution for UNIX and Linux systems.
Join Linux Journal's Shawn Powers and David Huffman, President/CEO, Storix, Inc.
Free to Linux Journal readers.Register Now!
- Server Hardening
- May 2016 Issue of Linux Journal
- EnterpriseDB's EDB Postgres Advanced Server and EDB Postgres Enterprise Manager
- The Humble Hacker?
- The US Government and Open-Source Software
- BitTorrent Inc.'s Sync
- The Death of RoboVM
- Open-Source Project Secretly Funded by CIA
- New Container Image Standard Promises More Portable Apps
- ACI Worldwide's UP Retail Payments
In modern computer systems, privacy and security are mandatory. However, connections from the outside over public networks automatically imply risks. One easily available solution to avoid eavesdroppers’ attempts is SSH. But, its wide adoption during the past 21 years has made it a target for attackers, so hardening your system properly is a must.
Additionally, in highly regulated markets, you must comply with specific operational requirements, proving that you conform to standards and even that you have included new mandatory authentication methods, such as two-factor authentication. In this ebook, I discuss SSH and how to configure and manage it to guarantee that your network is safe, your data is secure and that you comply with relevant regulations.Get the Guide