Toybox

Last updated
Toybox
Original author(s) Robert Landley
Developer(s) Robert Landley and others
Initial release2006;18 years ago (2006)
Stable release
0.8.10 / July 30, 2023;7 months ago (2023-07-30)
Repository
Written in C
Operating system Unix-like
Size 3.30 MB (archived)
Type Independent SUS XCU implementation
License 0BSD [1] [2]
Website www.landley.net/toybox

Toybox is a free and open-source software implementation of over 200 Unix command line utilities such as ls , cp , and mv . The Toybox project was started in 2006, [3] and became a 0BSD licensed BusyBox alternative. [4] [5] Toybox is used for most of Android's command-line tools in all currently supported Android versions, and is also used to build Android on Linux and macOS. All of the tools are tested on Linux, and many of them also work on BSD and macOS.

Contents

Functionality and aim

Toybox aims to provide a BSD licensed replacement for the GPL licensed BusyBox. [6] Toybox's major technical design goals are simplicity, smallness, speed and standard compliance. [7] Toybox aims to be mostly POSIX-2008 and LSB 4.1 compatible, and doesn't focus on having every option found in GNU counterparts. [3]

Toybox is licensed using the permissive 0BSD license, where BusyBox uses the copyleft GNU General Public License, which led to different usage domains. BusyBox is mostly used in the copyleft FOSS domain, while Toybox is used mostly with permissive licensed projects and by commercial companies, e.g. Google's Android, [8] which is an explicit target of Toybox. [9] Feature-wise, Toybox has not reached parity with BusyBox.

History

Toybox was started in early 2006 by Rob Landley [3] [5] after he ended his BusyBox maintainership due to a dispute with Bruce Perens, the original creator of BusyBox. [10]

In 2008, the project went dormant [4] until the end of 2011. Rob Landley resumed work on Toybox, starting with relicensing from the GPL-2.0-only license to the BSD-2-Clause license [11] [12] with the goal of superseding the Android command line implementation. [13]

At the beginning of 2012, Sony employee Tim Bird suggested creating a permissively licensed alternative to BusyBox. [6] In March 2013, the project was relicensed to an even more permissive 0BSD license. [14]

At the end of 2014, Toybox was integrated into the Android 6.0.x "Marshmallow" development branches for use on devices. [15] [8] [16] In 2018, a host Toybox prebuilt was added to AOSP to help make the Android build itself more hermetic. [17]

Controversy

In January 2012 the proposal of creating a BSD license alternative to the GPL licensed BusyBox project drew harsh criticism from Matthew Garrett for taking away the only relevant tool for copyright enforcement of the Software Freedom Conservancy group. [18] Rob Landley, who had started the BusyBox-based lawsuits, responded that this was intentional, explaining that the lawsuits had not benefited the project but that they had led to corporate avoidance, expressing a desire to stop the lawsuits "in whatever way I see fit". [19] [20] [21]

Project progress

The official Toybox documentation lists an overview of the available, partially available, and missing commands. [22] As of November 2021, Version 0.8.6 achieves approximately 80% of the project's implementation goals targeted for 1.0. [23]

List of Toybox Commands
  • acpi — Show status of power sources and thermal devices.
  • adduser, addgroup — Add a user or group to the system.
  • ar — Create, modify, and extract from archives.
  • arch — Print machine (hardware) name, same as uname -m.
  • arp — The Address Resolution Protocol (ARP)
  • arping — Send ARP REQUEST to a neighbour host
  • ascii — Display ascii character set.
  • at — Execute commands at a later time.
  • awk — pattern scanning and processing language.
  • base32 — Encode or decode in base32.
  • base64 — Encode or decode in base64.
  • basename — Return non-directory portion of a pathname removing suffix.
  • bc — Arbitrary-precision arithmetic language.
  • blkdiscard — Discard device sectors.
  • blkid — Print type, label and UUID of filesystem on a block device or image.
  • blockdev — Call ioctls on each listed block device.
  • bunzip2 — Decompress bzip2 files.
  • bzcat — Decompress bzip2 files to stdout.
  • cal — Print a calendar.
  • cat — Copy (concatenate) files to stdout.
  • catv — Display nonprinting characters as escape sequences.
  • cd — Change the working directory.
  • chattr — Change file attributes on a Linux file system.
  • chgrp — Change group of one or more files.
  • chmod — Change mode of listed files.
  • chown — Change owner of one or more files.
  • chroot — Run command within a new root directory.
  • chrt — Get/set a process' real-time scheduling policy and priority.
  • chsh — Change your login shell.
  • chvt — Change to virtual terminal number N.
  • cksum — For each file, output crc32 checksum value, length and name of file.
  • clear — Clear the screen.
  • cmp — Compare the contents of two files.
  • comm — Select or reject lines common to two files.
  • count — Copy stdin to stdout, displaying simple progress indicator to stderr.
  • cp — Copy files.
  • cpio — Copy files into and out of a "newc" format cpio archive.
  • crc32 — Output crc32 checksum for each file.
  • cut — Print selected parts of lines from each FILE to standard output.
  • dd — Convert and copy a file.
  • date — Set/get the current date/time.
  • devmem — Read/write physical address via /dev/mem.
  • df — Shows total/used/available disk space for each filesystem listed on the command line, or all currently mounted filesystems.
  • diff - Compare two files.
  • dirname — Show directory portion of path.
  • dmesg — Print or control the kernel ring buffer.
  • dnsdomainname — Show domain this system belongs to (same as hostname -d).
  • dos2unix — Convert newline format from dos "\r\n" to unix "\n".
  • du — Show disk usage, space consumed by files and directories.
  • echo — Write each argument to stdout, with one space between each, followed by a newline.
  • egrep — Show lines matching extended regular expressions.
  • eject — Eject DEVICE or default /dev/cdrom.
  • env — Set the environment for command invocation, or list environment variables.
  • expand — Expand tabs to spaces according to tabstops.
  • factor — Factor integers.
  • fallocate — Tell the filesystem to allocate space for a file.
  • false — Return nonzero.
  • fdisk — Manipulate disk partition table.
  • fgrep — Show lines matching regular expressions.
  • file — Examine the given files and describe their content types.
  • find — Search directories for matching files.
  • flock — Manage advisory file locks.
  • fold — Filter for folding lines.
  • fmt — Reformat input to wordwrap at a given line length, preserving existing indentation level, writing to stdout.
  • free — Display the total, free and used amount of physical memory and swap space.
  • freeramdisk — Free all memory allocated to specified ramdisk.
  • fsfreeze — Freeze or unfreeze a filesystem.
  • fstype — Print type of filesystem on a block device or image.
  • fsync — Synchronize a file's in-core state with storage device.
  • ftpget — Use File Transfer Protocol (FTP) to get a file from an FTP server.
  • ftpput — Use File Transfer Protocol (FTP) to put a file to an FTP server.
  • getconf — Get system configuration values.
  • grep — Show lines matching regular expressions.
  • groups — Print the groups a user is in.
  • gunzip — Decompress gz files.
  • halt — Restart, halt or powerdown the system.
  • head — Copy first lines from files to stdout.
  • help — Show usage information for toybox commands.
  • hexedit — Hexadecimal file editor.
  • hostname — Get/set the current hostname.
  • hwclock — Get/set the hardware clock.
  • i2cdetect — Detect i2c devices.
  • i2cdump — Dump i2c registers.
  • i2cget — Read an i2c register.
  • i2cset — Write an i2c register.
  • iconv — Convert character encoding of files.
  • id — Print user and group ID.
  • ifconfig — Display or configure network interface.
  • inotifyd — Run a program when a filesystem event occurs.
  • insmod — Load the module named MODULE passing options if given.
  • install — Copy files and set attributes.
  • ionice — Change the I/O scheduling priority of a process.
  • iorenice — Display or change I/O priority of existing process.
  • iotop — Rank processes by I/O.
  • kill — Send signal to process.
  • killall — Send a signal (default: TERM) to all processes with the given names.
  • killall5 — Send a signal to all processes outside current session.
  • less — opposite of more
  • link — Create hardlink to a file.
  • ln — Create a link between FROM and TO.
  • logger — Log message (or stdin) to syslog.
  • login — Log in as a user, prompting for username and password if necessary.
  • logname — Print the current user name.
  • losetup — Associate a loopback device with a file, or show current file (if any) associated with a loop device.
  • ls — List files.
  • lsattr — List file attributes on a Linux file system.
  • lsmod — Display the currently loaded modules, their sizes and their dependencies.
  • lspci — List PCI devices.
  • lsusb — List USB hosts/devices.
  • makedevs — Create a range of special files as specified in a device table.
  • mcookie — Generate a 128-bit strong random number.
  • md5sum — Calculate md5 hash for each input file, reading from stdin if none.
  • microcom — Simple serial console.
  • mix — List OSS sound channels (module snd-mixer-oss), or set volumes.
  • mkdir — Create one or more directories.
  • mkfifo — Create FIFOs (named pipes).
  • mknod — Create a special file NAME with a given type.
  • mkpasswd — Crypt PASSWORD using crypt(3).
  • mkswap — Set up a Linux swap area on a device or file.
  • mktemp — Safely create a new file "DIR/TEMPLATE" and print its name.
  • modinfo — Display module fields for modules specified by name or .ko path.
  • mount — Mount new filesystems on directories.
  • mountpoint — Check whether the directory or device is a mountpoint.
  • mv — Move files.
  • nbd-client — Connect to an NBD server.
  • nc/netcat — Forward stdin/stdout to a file or network connection.
  • netstat — Display networking information.
  • nice — Run a command line at an increased or decreased scheduling priority.
  • nl — Number lines of input.
  • nohup — Run a command that survives the end of its terminal.
  • nproc — Print number of processors.
  • nsenter — Run COMMAND in an existing (set of) namespaces.
  • od — Dump data in octal/hex.
  • oneit — Simple init program that runs a single supplied command line
  • partprobe — Tell the kernel about partition table changes.
  • passwd — Update user's authentication tokens.
  • paste — Merge corresponding lines from each input file.
  • patch — Apply a unified diff to one or more files.
  • pgrep — Search for process(es).
  • pidof — Print the PIDs of all processes with the given names.
  • ping — Check network connectivity by sending packets to a host and reporting its response.
  • pivot root — Swap OLD and NEW filesystems (as if by simultaneous mount—move), and move all processes with chdir or chroot under OLD into NEW (including kernel threads) so OLD may be unmounted.
  • pkill — look up or signal processes based on name and other
  • pmap — Report the memory map of a process or processes.
  • poweroff — Restart, halt or powerdown the system.
  • printenv — Print environment variables.
  • printf — Format and print ARGUMENT according to FORMAT, using C printf syntax.
  • prlimit — Print or set resource limits for process number PID.
  • ps — List processes.
  • pwd — Print working (current) directory.
  • pwdx — Print working directory of processes listed on command line.
  • readahead — Preload files into disk cache.
  • readlink — Show what symlink points to.
  • realpath — Display the canonical absolute pathname
  • reboot — Restart, halt or powerdown the system.
  • renice — set nice values of running processes
  • reset — Reset the terminal.
  • rev — Output each line reversed, when no files are given stdin is used.
  • rfkill — Enable/disable wireless devices.
  • rm — Remove each argument from the filesystem.
  • rmdir — Remove one or more directories.
  • rmmod — Unload the module named MODULE from the Linux kernel.
  • rtcwake — Enter the given sleep state until the given time.
  • sed — Stream editor.
  • seq — Count from first to last, by increment.
  • setfattr — Write POSIX extended attributes.
  • setsid — Run process in a new session.
  • sha1sum — Calculate sha hash for each input file, reading from stdin if none.
  • shred — Securely delete a file by overwriting its contents with random data.
  • sleep — Wait before exiting.
  • sntp — Simple Network Time Protocol client.
  • sort — Sort all lines of text from input files (or stdin) to stdout.
  • split — Copy INPUT (or stdin) data to a series of OUTPUT (or "x") files with alphabetically increasing suffix (aa, ab, ac... az, ba, bb...).
  • stat — Display status of files or filesystems.
  • strings — Display printable strings in a binary file
  • su — Switch user, prompting for password of new user when not run as root.
  • swapoff — Disable swapping on a given swapregion.
  • swapon — Enable swapping on a given device/file.
  • switch root — Use from PID 1 under initramfs to free initramfs, chroot to NEW_ROOT, and exec NEW_INIT.
  • sync — Write pending cached data to disk (synchronize), blocking until done.
  • sysctl — Read/write system control data (under /proc/sys).
  • tac — Output lines in reverse order.
  • tail — Copy last lines from files to stdout.
  • tar — Create, extract, or list files in a .tar (or compressed t?z) file.
  • taskset — Launch a new task which may only run on certain processors, or change the processor affinity of an existing PID.
  • tee — Copy stdin to each listed file, and also to stdout.
  • test — Return true or false by performing tests.
  • time — Run command line and report real, user, and system time elapsed in seconds.
  • timeout — Run command line as a child process, sending child a signal if the command doesn't exit soon enough.
  • top — Show process activity in real time.
  • touch — Update the access and modification times of each FILE to the current time.
  • true — Return zero.
  • truncate — Set length of files, extending sparsely if necessary.
  • tty — Show filename of terminal connected to stdin.
  • tunctl — Create and delete tun/tap virtual Ethernet devices.
  • ulimit — Print or set resource limits for process number PID.
  • umount — Unmount the listed filesystems.
  • uname — Print system information.
  • unicode — universal character set.
  • uniq — Report or filter out repeated lines in a file.
  • unix2dos — Convert newline format from unix "\n" to dos "\r\n".
  • unlink — Delete one file.
  • unshare — Create new container namespace for this process and its children, so some attribute is not shared with the parent process.
  • uptime — Tell the current time, how long the system has been running, the number of users, and the system load averages for the past 1, 5 and 15 minutes.
  • usleep — Pause for MICROSECONDS microseconds.
  • uudecode — Decode a uuencoded file.
  • uuencode — Encode a binary file.
  • uuidgen — Create and print a new RFC4122 random UUID.
  • vconfig — Create and remove virtual Ethernet devices.
  • vmstat — Print virtual memory statistics.
  • w — Show who is logged on and since how long they logged in.
  • watch — Run PROG every -n seconds, showing output.
  • wc — Count lines, words, and characters in input.
  • which — Search $PATH for executable files matching filenames.
  • watchdog — software watchdog daemon.
  • who — Print information about logged in users.
  • whoami — Print the current user name.
  • xargs — Run command line one or more times, appending arguments from stdin.
  • xxd — Hexdump a file to stdout.
  • yes — Repeatedly output line until killed.
  • zcat — Decompress gz files to stdout.

See also

Related Research Articles

<span class="mw-page-title-main">C shell</span> Unix shell

The C shell is a Unix shell created by Bill Joy while he was a graduate student at University of California, Berkeley in the late 1970s. It has been widely distributed, beginning with the 2BSD release of the Berkeley Software Distribution (BSD) which Joy first distributed in 1978. Other early contributors to the ideas or the code were Michael Ubell, Eric Allman, Mike O'Brien and Jim Kulp.

In computer programming, standard streams are preconnected input and output communication channels between a computer program and its environment when it begins execution. The three input/output (I/O) connections are called standard input (stdin), standard output (stdout) and standard error (stderr). Originally I/O happened via a physically connected system console, but standard streams abstract this. When a command is executed via an interactive shell, the streams are typically connected to the text terminal on which the shell is running, but can be changed with redirection or a pipeline. More generally, a child process inherits the standard streams of its parent process.

In computing, a loadable kernel module (LKM) is an object file that contains code to extend the running kernel, or so-called base kernel, of an operating system. LKMs are typically used to add support for new hardware and/or filesystems, or for adding system calls. When the functionality provided by an LKM is no longer required, it can be unloaded in order to free memory and other resources.

In Unix and Unix-like computer operating systems, a file descriptor is a process-unique identifier (handle) for a file or other input/output resource, such as a pipe or network socket.

<span class="mw-page-title-main">BusyBox</span> Collection of Unix tools

BusyBox is a software suite that provides several Unix utilities in a single executable file. It runs in a variety of POSIX environments such as Linux, Android, and FreeBSD, although many of the tools it provides are designed to work with interfaces provided by the Linux kernel. It was specifically created for embedded operating systems with very limited resources. The authors dubbed it "The Swiss Army knife of Embedded Linux", as the single executable replaces basic functions of more than 300 common commands. It is released as free software under the terms of the GNU General Public License v2, after controversially deciding not to move to version 3.

The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.

These tables provide a comparison of operating systems, of computer devices, as listing general and technical information for a number of widely used and currently available PC or handheld operating systems. The article "Usage share of operating systems" provides a broader, and more general, comparison of operating systems that includes servers, mainframes and supercomputers.

The proc filesystem (procfs) is a special filesystem in Unix-like operating systems that presents information about processes and other system information in a hierarchical file-like structure, providing a more convenient and standardized method for dynamically accessing process data held in the kernel than traditional tracing methods or direct access to kernel memory. Typically, it is mapped to a mount point named /proc at boot time. The proc file system acts as an interface to internal data structures about running processes in the kernel. In Linux, it can also be used to obtain information about the kernel and to change certain kernel parameters at runtime (sysctl).

GNU Readline is a software library that provides in-line editing and history capabilities for interactive programs with a command-line interface, such as Bash. It is currently maintained by Chet Ramey as part of the GNU Project.

In Linux systems, initrd is a scheme for loading a temporary root file system into memory, to be used as part of the Linux startup process. initrd and initramfs refer to two different methods of achieving this. Both are commonly used to make preparations before the real root file system can be mounted.

<span class="mw-page-title-main">Linux</span> Family of Unix-like operating systems

Linux is a family of open-source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991, by Linus Torvalds. Linux is typically packaged as a Linux distribution (distro), which includes the kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses and recommends the name "GNU/Linux" to emphasize the use and importance of GNU software in many distributions, causing some controversy.

sha1sum is a computer program that calculates and verifies SHA-1 hashes. It is commonly used to verify the integrity of files. It is installed by default on most Linux distributions. Typically distributed alongside sha1sum are sha224sum, sha256sum, sha384sum and sha512sum, which use a specific SHA-2 hash function and b2sum, which uses the BLAKE2 cryptographic hash function.

chattr is the command in Linux that allows a user to set certain attributes of a file. lsattr is the command that displays the attributes of a file.

<span class="mw-page-title-main">GNU Emacs</span> GNU version of the Emacs text editor

GNU Emacs is a free software text editor. It was created by GNU Project founder Richard Stallman, based on the Emacs editor developed for Unix operating systems. GNU Emacs has been a central component of the GNU project and a flagship project of the free software movement. Its tag line is "the extensible self-documenting text editor."

In Unix-like operating systems, a device file or special file is an interface to a device driver that appears in a file system as if it were an ordinary file. There are also special files in DOS, OS/2, and Windows. These special files allow an application program to interact with a device by using its device driver via standard input/output system calls. Using standard system calls simplifies many programming tasks, and leads to consistent user-space I/O mechanisms regardless of device features and functions.

<span class="mw-page-title-main">GNU General Public License</span> Series of free software licenses

The GNU General Public License is a series of widely used free software licenses or copyleft that guarantee end users the four freedoms to run, study, share, and modify the software. The license was the first copyleft for general use and was originally written by Richard Stallman, the founder of the Free Software Foundation (FSF), for the GNU Project. The license grants the recipients of a computer program the rights of the Free Software Definition. These GPL series are all copyleft licenses, which means that any derivative work must be distributed under the same or equivalent license terms. It is more restrictive than the Lesser General Public License and even further distinct from the more widely used permissive software licenses BSD, MIT, and Apache.

"Everything is a file" is an idea that Unix, and its derivatives, handle input/output to and from resources such as documents, hard-drives, modems, keyboards, printers and even some inter-process and network communications as simple streams of bytes exposed through the filesystem name space. Exceptions include semaphores, processes and threads.

Bionic is an implementation of the standard C library, developed by Google for its Android operating system. It differs from the GNU C Library (glibc) in being designed for devices with less memory and processor power than a typical Linux system. It is a combination of new code and code from FreeBSD, NetBSD, and OpenBSD released under a BSD license, rather than glibc, which uses the GNU Lesser General Public License. This difference was important in the early days of Android, when static linking was common, and since bionic has its own ABI, it can't be replaced by a different libc without breaking all existing apps.

<span class="mw-page-title-main">OpenZFS</span> Open-source implementation of the ZFS file system

OpenZFS is an open-source implementation of the ZFS file system and volume manager initially developed by Sun Microsystems for the Solaris operating system and now maintained by the OpenZFS Project. It supports features like data compression, data deduplication, copy-on-write clones, snapshots, and RAID-Z. It also supports the creation of virtual devices, which allows for the creation of file systems that span multiple disks.

References

  1. Toybox is released under the following "zero clause" BSD license by Rob Landley
  2. "Simplify license text, as mentioned on the mailing list". 2013-03-14. Retrieved 2021-06-29.
  3. 1 2 3 Landley, Robert. "What is ToyBox?". Toybox project website. Retrieved 13 July 2012.
  4. 1 2 Dj Walker-Morgan. "Inside the ToyBox: An interview with Rob Landley" . Retrieved 13 July 2012.
  5. 1 2 Varghese, Sam (2012-02-01). "BusyBox replacement project fuels animated verbal spat". IT Wire. Retrieved 2013-05-12.
  6. 1 2 "Busybox replacement project". 2012-01-11. Retrieved 2014-03-04.
  7. Landley, Robert. "Design Docs". Toybox project website. Retrieved 18 February 2015. Toybox combines the most common Linux command line utilities together into a single BSD-licensed executable. It's simple, small, fast, and reasonably standards-compliant (POSIX-2008 and LSB 4.1).
  8. 1 2 toybox on android.googlesource.com (2014-12-28)
  9. celf-2015.txt by Rob Landley (2015)
  10. Landley, Robert (2006-09-30). "I'm going out now. I may be some time". busybox (Mailing list).
  11. Toybox relaunch on toybox.landley.narkive.com (2011-11-20)
  12. Switch to 2-clause BSD license (with caveat about scripts directory). 0.2.0 by landley on 15 Nov 2011
  13. "Toybox news".
  14. Simplify license text, as mentioned on the mailing list. by Landley (14 Mar 2013)
  15. Android gets a toybox on lwn.net by Jake Edge (January 14, 2015)
  16. Issue 76861: Importing parts of Toybox into Android, including dos2unix, unix2dos, sort, uniq, and usleep
  17. "Start using the toybox prebuilt".
  18. "Garrett: The ongoing fight against GPL enforcement". LWN.net. 2012-01-31. Retrieved 2014-03-04. The real problem here is that the [Software Freedom Conservancy's] reliance on Busybox means that they're only able to target infringers who use that Busybox code. No significant kernel copyright holders have so far offered to allow the SFC to enforce their copyrights, with the result that enforcement action will grind to a halt as vendors move over to this Busybox replacement.
  19. "Garrett: The ongoing fight against GPL enforcement". LWN.net. 2012-01-31. Retrieved 2014-03-04. >As the ex-maintainer of busybox who STARTED those lawsuits in the first place and now HUGELY REGRETS ever having done so, I think I'm entitled to stop the lawsuits in whatever way I see fit. They never resulted in a single line of code added to the busybox repository. They HAVE resulted in more than one company exiting Linux development entirely and switching to non-Linux operating systems for their embedded products, and they're a big part of the reason behind Android's "No GPL in userspace" policy.
  20. Proffitt, Brian (2012-02-02). "GPL enforcement sparks community flames - Throwing the GPL baby out with the enforcement bath water?". ITworld. Retrieved 2015-03-04.
  21. Landley, Rob. "Embedded Linux Conference 2013 - Toybox: Writing a New Command Line" (video). The Linux Foundation. Archived from the original on 2021-12-21. Retrieved 2016-06-24.
  22. Toybox Status
  23. Project progress for 0.8.7