Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

A static binary that contains a huge variety of useful posix commands (ls/cp/mv/cat/md5sum/nohup/mount etc etc), all baked into one program, which exhibits different behaviour depending on how it is called - if you name the executable to one of these, or provide a hard or soft link with that name, it will behave as that program.

This generally makes things easier on devices with strict storage space constraints by reducing the overhead of having separate executables and/or libraries for the code for all these. It may reduce load times in very constrained systems compared to dynamic linking too, as everything is bundled in the one image, and in some cases it can exhibit performance gains.

It's generally (but not exclusively) of interest to embedded device manufacturers. Toybox is licensed very permissively, compared to busybox's use of GPL, so manufacturers like it. IIRC it is now used in android.



The Nixpkgs search page for it https://search.nixos.org/packages?channel=25.05&show=toybox&... shows the list of its outputs (executables):

    [ acpi arch ascii base32 base64 basename blkdiscard blkid blockdev bunzip2 bzcat cal cat chattr chgrp chmod chown chroot chrt chvt cksum clear cmp comm count cp cpio crc32 cut date dd deallocvt devmem df dirname dmesg dnsdomainname dos2unix du echo egrep eject env expand factor fallocate false fgrep file find flock fmt fold free freeramdisk fsfreeze fstype fsync ftpget ftpput getconf getopt gpiodetect gpiofind gpioget gpioinfo gpioset grep groups gunzip halt head help hexedit host hostname httpd hwclock i2cdetect i2cdump i2cget i2cset i2ctransfer iconv id ifconfig inotifyd insmod install ionice iorenice iotop kill killall killall5 link linux32 ln logger login logname losetup ls lsattr lsmod lspci lsusb makedevs mcookie md5sum memeater microcom mix mkdir mkfifo mknod mkpasswd mkswap mktemp modinfo mount mountpoint mv nbd-client nbd-server nc netcat netstat nice nl nohup nproc nsenter od oneit openvt partprobe paste patch pgrep pidof ping ping6 pivot_root pkill pmap poweroff printenv printf prlimit ps pwd pwdx pwgen readahead readelf readlink realpath reboot renice reset rev rfkill rm rmdir rmmod rtcwake sed seq setfattr setsid sha1sum sha224sum sha256sum sha384sum sha3sum sha512sum shred shuf sleep sntp sort split stat strings su swapoff swapon switch_root sync sysctl tac tail tar taskset tee test time timeout top touch toybox true truncate ts tsort tty tunctl uclampset ulimit umount uname unicode uniq unix2dos unlink unshare uptime usleep uudecode uuencode uuidgen vconfig vmstat w watch watchdog wc wget which who whoami xargs xxd yes zcat
That's... an impressive set of Unix functionality in a single binary... AFAIK, if this works like Busybox does, these are all actually just wrappers that call into Toybox with this command as a parameter. EDIT: Nope, it's literally just symlinks with names detected by toybox that dictate how it will behave, and this is apparently called a "multicall binary"

And yes, the [ (open bracket) is a command in POSIX shell.


Just for reference. Here is the full list of completed and in-progress commands from the toybox website:

https://landley.net/toybox/status.html

And here is the list of the Linux standard core commands (toybox covers more than this):

https://refspecs.linuxfoundation.org/LSB_4.1.0/LSB-Core-gene...


ah, Awk would be nice, from the in-progress list


thanks, that is the most understandable explanation I've seen!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: