xref: /aosp_15_r20/external/toybox/www/quick.html (revision cf5a6c84e2b8763fc1a7db14496fd4742913b199)
1<html><head><title>Toybox quick start</title>
2<!--#include file="header.html" -->
3
4<p>Toybox is a single executable implementing <a href=help.html>over
5two hundred</a> different Linux command line utilities. By default it
6uses its filename to determine which command to run, so it can be installed
7with symlinks like "<b>ln -s toybox sed</b>" to put all the commands into
8the search $PATH. The special name "<b>toybox</b>" uses its first argument
9as the command to run, ala "<b>toybox df -a</b>", so you can use it without
10installing it. Running "<b>toybox</b>" with no arguments lists the available
11commands.</p>
12
13<p>Each toybox command has built-in <a href=help.html>documentation</a>,
14which you can read in three different ways:</p>
15<ol>
16<li>most commands accept --help and --version arguments (ala <b>sed --help</b>),
17although some (such as <b>true</b> and <b>false</b>) ignore all arguments.</li>
18<li>toybox has a "<b>help</b>" command (ala <b>help sed</b> or
19<b>toybox help sed</b>).</li>
20<li><b>toybox --help command</b> lets you and ask toybox
21for --help about commands. Run "<b>toybox --help</b>" with no other arguments
22to see <a href=help.html#toybox>general help</a> about toybox.</li>
23</ol>
24
25<p>You can download a <a href=https://landley.net/bin/toybox/latest>toybox
26binary</a> and try it out like so:</p>
27
28<blockquote><p>
29$ wget http://landley.net/bin/toybox/latest/toybox-x86_64 -O toybox<br />
30$ chmod +x toybox<br />
31$ ./toybox echo hello<br />
32$ ./toybox ls -l --color
33</p></blockquote>
34
35<p>Installing toybox into the $PATH looks something like:</p>
36
37<blockquote><p>
38$ mkdir newdir<br />
39$ mv toybox newdir/<br />
40$ for i in $(newdir/toybox); do ln -s toybox newdir/$i; done<br />
41$ export PATH="$PWD/newdir:$PATH"<br />
42$ ls --help
43</p></blockquote>
44
45<p>To compile toybox from source:</p>
46
47<blockquote><p>
48$ git clone https://github.com/landley/toybox<br />
49$ cd toybox<br />
50$ make defconfig toybox<br />
51$ ./toybox<br />
52$ make tests<br />
53</p></blockquote>
54
55<p>Toybox's build has "<b>make menuconfig</b>" like the kernel (and the
56usual targets: clean, distclean, allnoconfig...), run "<b>make help</b>"
57to list more options.</p>
58
59<p>The binaries distributed on the website are statically linked against musl-libc
60to provide a portable executable without external userspace dependencies.
61To reproduce that:</p>
62
63<blockquote><p>
64$ git clone https://github.com/landley/toybox<br />
65$ cd toybox<br />
66$ wget https://landley.net/bin/toolchains/latest/x86_64-linux-musl-cross.tar.xz<br />
67$ tar xvf x86_64-linux-musl-cross.tar.xz<br />
68$ LDFLAGS=--static CROSS_COMPILE=x86_64-linux-musl-cross/bin/x86_64-linux-musl- make defconfig toybox<br />
69$ ./toybox
70</p></blockquote>
71
72<p>You can also build individual toybox commands as standalone executables,
73either by name ("<b>make sed</b>") or using the "<b>make change</b>" target (as in change
74for a $20) to build all of them at once. This is much less efficient than
75the default build, the individual commands add up to around ten times the
76size of the equivalent all-in-one toybox binary.</p>
77
78<!--#include file="footer.html" -->
79