toybox

About Download Development docs Contact

Current release 0.8.10 (July 30, 2023)


Toybox is a single executable implementing over two hundred different Linux command line utilities. By default it uses its filename to determine which command to run, so it can be installed with symlinks like "ln -s toybox sed" to put all the commands into the search $PATH. The special name "toybox" uses its first argument as the command to run, ala "toybox df -a", so you can use it without installing it. Running "toybox" with no arguments lists the available commands.

Each toybox command has built-in documentation, which you can read in three different ways:

  1. most commands accept --help and --version arguments (ala sed --help), although some (such as true and false) ignore all arguments.
  2. toybox has a "help" command (ala help sed or toybox help sed).
  3. toybox --help command lets you and ask toybox for --help about commands. Run "toybox --help" with no other arguments to see general help about toybox.

You can download a toybox binary and try it out like so:

$ wget http://landley.net/bin/toybox/latest/toybox-x86_64 -O toybox
$ chmod +x toybox
$ ./toybox echo hello
$ ./toybox ls -l --color

Installing toybox into the $PATH looks something like:

$ mkdir newdir
$ mv toybox newdir/
$ for i in $(newdir/toybox); do ln -s toybox newdir/$i; done
$ export PATH="$PWD/newdir:$PATH"
$ ls --help

To compile toybox from source:

$ git clone https://github.com/landley/toybox
$ cd toybox
$ make defconfig toybox
$ ./toybox
$ make tests

Toybox's build has "make menuconfig" like the kernel (and the usual targets: clean, distclean, allnoconfig...), run "make help" to list more options.

The binaries distributed on the website are statically linked against musl-libc to provide a portable executable without external userspace dependencies. To reproduce that:

$ git clone https://github.com/landley/toybox
$ cd toybox
$ wget https://landley.net/bin/toolchains/latest/x86_64-linux-musl-cross.tar.xz
$ tar xvf x86_64-linux-musl-cross.tar.xz
$ LDFLAGS=--static CROSS_COMPILE=x86_64-linux-musl-cross/bin/x86_64-linux-musl- make defconfig toybox
$ ./toybox

You can also build individual toybox commands as standalone executables, either by name ("make sed") or using the "make change" target (as in change for a $20) to build all of them at once. This is much less efficient than the default build, the individual commands add up to around ten times the size of the equivalent all-in-one toybox binary.