Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I remember that for Linux running in embedded systems, due to size limitations, it can't pack as many commands as in ordinary workstations. So there is a do-it-all command that can mimic almost all the commands (including ls, cd, time, etc.), but I don't remember its name.

I just vaguely remembered something like "minibox" or something, it seems like has a "box" in its name, does anyone know what is its name?

share|improve this question
12  
It's called busybox. –  MariusMatutiae Jun 27 at 9:20
    
Yes, that's it, thanks very much. –  wangshuaijie Jun 27 at 9:21
6  
It won't mimic cd though, that's not possible. –  OrangeDog Jun 27 at 14:48
4  
@OrangeDog: ...but it will mimic sh, which has cd as a built-in. –  Ilmari Karonen Jun 27 at 21:28
5  
D'oh, I was going to say emacs... –  R.. Jun 29 at 16:52

3 Answers 3

up vote 48 down vote accepted

The most popular could be BusyBox, but there are also toolbox (used by Android), toybox and maybe others.

share|improve this answer
    
It's worth clarifying that Busybox is an installer, not a single magic binary. At least not for Android. Busybox is an installer for tools that aren't natively on the device. It looks at the binaries already on the device and adds to them. For me, it placed the new binaries in /system/xbin/. –  Corey Ogburn Jun 29 at 17:18
1  
@Corey are you sure? its about page says "BusyBox combines tiny versions of many common UNIX utilities into a single small executable.". –  RedGrittyBrick Jun 29 at 17:22
    
Absolutely. I'm not as sure about iOS, but in Android you have to install BusyBox. The app itself let's you pick which version of busybox and where to install them. Mine currently says "BusyBox v1.22.1-Stericson is installed. BusyBox is installed to /system/xbin". You can look at the list of installed binaries and find them in /system/xbin/. It's not a shell, it's not an all-in-one binary, it's a bundle of binaries and an easy installer. –  Corey Ogburn Jun 29 at 17:27
2  
@CoreyOgburn: The original BusyBox is the application itself. The Android app, although named BusyBox, is only an app that installs the "real" BusyBox. BusyBox itself is basicly the same, be it on Android, iOS, BSD or whatever other system. Only the installers may differ. –  Michael Ehrenreich Jun 29 at 19:25
3  
And the "many executables" isn't true either; busybox creates a ton of symbolic links to itself. E.g. grep probably is a link to busybox. The one exception is going to be cd as that has to be a shell built-in. –  MSalters Jun 29 at 22:36

You’re probably referring to Busybox, an “all-in-one” shell.

share|improve this answer
    
Yes, that's it, thanks. –  wangshuaijie Jun 27 at 9:21

BusyBox is designed in a fairly novel way that can be quite confusing when you start rummaging around in your /bin directories.

As MSalters indicated, BusyBox is just one executable. But it depends on a symbolic link being created to that executable for every "command" in it. By knowing the symlink name it was started with, it knows to run the C function for that command.

Thus, the start of my PuppyLinux 5.2.8 Lucid /bin directory looks like ...

sh-4.1# ls -l
total 4889
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 [ -> busybox
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 [[ -> busybox
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 addgroup -> busybox
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 adduser -> busybox
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 ash -> busybox
-rwxr-xr-x 1 root root   2844 2011-08-17 11:04 autologinroot
lrwxrwxrwx 1 root root      4 2011-08-17 10:49 awk -> gawk
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 basename -> busybox
-rwxr-xr-x 1 root root 805960 2011-08-17 11:04 bash
-r-xr-xr-x 1 root root   6835 2011-01-21 01:29 bashbug
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 bbconfig -> busybox
-rwxr-xr-x 1 root root  30200 2011-08-17 11:04 bunzip2
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 bunzip2-BB-NOTUSED -> busybox
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 busybox
-rwxr-xr-x 1 root root  30200 2011-08-17 11:04 bzcat
lrwxrwxrwx 1 root root      7 2011-08-17 10:49 bzcat-BB-NOTUSED -> busybox

Note that most commands are symlinks to busybox. This includes the ash very minimalist shell used mostly during boot operations. Also note that the distribution author chose to include the standalone commands bunzip2 and bzcat instead of using the busybox versions. The symlinks bunzip-BB-NOTUSED and bzcat-BB-NOTUSED are not really necessary but help document what's going on for just the cost of a symlink.

Note also that a directory listing that reports sizes for the target of symlinks (ls -lL or ls -l --dereference) instead of the symlink itself, will report the size of each command as the same as that of busybox. Thus the same list with the -L option shows ...

sh-4.1# ls -lL
total 60402
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 [
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 [[
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 addgroup
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 adduser
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 ash
-rwxr-xr-x 1 root root   2844 2011-08-17 11:04 autologinroot
-rwxr-xr-x 1 root root 317880 2011-08-17 11:04 awk
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 basename
-rwxr-xr-x 1 root root 805960 2011-08-17 11:04 bash
-r-xr-xr-x 1 root root   6835 2011-01-21 01:29 bashbug
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 bbconfig
-rwxr-xr-x 1 root root  30200 2011-08-17 11:04 bunzip2
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 bunzip2-BB-NOTUSED
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 busybox
-rwxr-xr-x 1 root root  30200 2011-08-17 11:04 bzcat
-rwxr-xr-x 1 root root 637960 2011-08-17 11:04 bzcat-BB-NOTUSED

The objective of BusyBox is maximum reuse of code within itself in order to minimize the memory and disk space required (i.e. the "footprint") for a common set of commands... without requiring a shell itself.

Bash and other shells accomplish the same thing. But to do so, they implement their own commandline environment. This objective is also one of the reasons for some of the very archaic syntax for many shell functionalities.

I'm currently using this "BusyBox technique" for a library of Bash functions and easier to use wrappers for various bashisms. It has let me easily "extend" commands with --help options and fire off GUI versions when available.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.