BusyBox: Difference between revisions

From Alpine Linux
(added reference to Editing How to get regular stuff working page)
(reworded sentence and moved headings)
 
(10 intermediate revisions by the same user not shown)
Line 1: Line 1:
Alpine Linux is built around musl libc and [https://www.busybox.net/ busybox]. To minimize footprint, Alpine Linux comes with BusyBox by default. BusyBox provides replacements for most of the utilities usually found in GNU coreutils, util-linux, etc. Built-in utility programs called as applets share code for many common operations. Invoking BusyBox with no argument lists the applets that have been compiled into BusyBox binary. Refer [https://busybox.net/downloads/BusyBox.html BusyBox Manual] for options supported by BusyBox.
Alpine Linux is built around musl libc and [https://www.busybox.net/ busybox]. To minimize footprint, Alpine Linux comes with BusyBox by default.


BusyBox is set up as an endpoint for numerous symlinks that substitute various utilities. The utilities in BusyBox generally have fewer options and hence missing some functionality. Refer [[How to get regular stuff working]] page for installing the relevant packages to replace BusyBox symlinks.
BusyBox provides replacements for most of the utilities usually found in GNU coreutils, util-linux, etc. Built-in utility programs called as [[#BusyBox applets|applets]] share code for many common operations. BusyBox is set up as an endpoint for numerous symlinks that substitute various utilities. The utilities in BusyBox generally have fewer options than their full-featured GNU counterparts.


== Ash shell ==
== BusyBox applets ==
 
The command {{ic|$ busybox}} lists the applets that have been compiled into BusyBox binary, the output of which, as of [[Release_Notes_for_Alpine_3.22.0|v3.22]], is shown below: {{Cmd|<nowiki>$ busybox
BusyBox v1.37.0 (2025-08-05 16:40:33 UTC) multi-call binary.
BusyBox is copyrighted by many authors between 1998-2015.
Licensed under GPLv2. See source distribution for detailed
copyright notices.
 
Usage: busybox [function [arguments]...]
  or: busybox --list[-full]
  or: busybox --install [-s] [DIR]
  or: function [arguments]...
 
BusyBox is a multi-call binary that combines many common Unix
utilities into a single executable.  Most people will create a
link to busybox for each function they wish to use and BusyBox
will act like whatever it was invoked as.


Alpine Linux uses Busybox Ash for its default shell. To change the default shell to other shells like {{Pkg|bash}}, {{Pkg|zsh}}, {{Pkg|fish}} etc..refer [[Change default shell|change default shell]].
Currently defined functions:
[, [[, acpid, add-shell, addgroup, adduser, adjtimex, arch, arp, arping, ash, awk, base64, basename, bbconfig, bc, beep, blkdiscard, blkid, blockdev, brctl, bunzip2,
bzcat, bzip2, cal, cat, chattr, chgrp, chmod, chown, chpasswd, chroot, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw, cut, date, dc, dd,
deallocvt, delgroup, deluser, depmod, df, diff, dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env, ether-wake, expand, expr, factor,
fallocate, false, fatattr, fbset, fbsplash, fdflush, fdisk, fgrep, find, findfs, flock, fold, free, fsck, fstrim, fsync, fuser, getopt, getty, grep, groups, gunzip,
gzip, halt, hd, head, hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifenslave, ifup, init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc,
ipcrm, ipcs, iplink, ipneigh, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, last, less, link, linux32, linux64, ln, loadfont, loadkmap,
logger, login, logread, losetup, ls, lsattr, lsmod, lsof, lsusb, lzcat, lzma, lzop, lzopcat, makemime, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mkfifo,
mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mv, nameif, nanddump, nandwrite, nbd-client, nc, netstat, nice, nl,
nmeter, nohup, nologin, nproc, nsenter, nslookup, ntpd, od, openvt, partprobe, passwd, paste, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap,
poweroff, printenv, printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, rdev, readahead, readlink, realpath, reboot, reformime, remove-shell, renice, reset,
resize, rev, rfkill, rm, rmdir, rmmod, route, run-parts, sed, sendmail, seq, setconsole, setfont, setkeycodes, setlogcons, setpriv, setserial, setsid, sh, sha1sum,
sha256sum, sha3sum, sha512sum, showkey, shred, shuf, slattach, sleep, sort, split, stat, strings, stty, su, sum, swapoff, swapon, switch_root, sync, sysctl, syslogd,
tac, tail, tar, tee, test, time, timeout, top, touch, tr, traceroute, traceroute6, tree, true, truncate, tty, ttysize, tunctl, udhcpc, udhcpc6, umount, uname,
unexpand, uniq, unix2dos, unlink, unlzma, unlzop, unshare, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, volname, watch, watchdog, wc, wget,
which, who, whoami, whois, xargs, xxd, xzcat, yes, zcat, zcip</nowiki>}}  


=== Aliases ===
To view options supported by a specific BusyBox applet, say {{ic|grep}}, issue the command {{ic|$ busybox grep -h}}


When using Ash shell, one can’t set aliases in the {{Path|~/.profile}}, but environment variables can be set in it. In order to use aliases with Busybox Ash, you must set the ENV environment variable to refer the aliases file.
== Replacing BusyBox utilities ==


First create the file {{Path|/etc/profile.d/profile.sh}} as follows:
If you find certain utilities in busybox lacking in features or options, equivalent [[How to get regular stuff working|full-featured utilities can easily replace]] them. This may be particularly useful when intially setting up hardware like [[Sound Setup|sound]], [[Configure Networking|networking]], [[Graphics driver|graphics]] and [[Printer Setup|printers]] and can be removed once done.
{{Cat|/etc/profile.d/profile.sh|if [ -f "$HOME/.config/ash/profile" ]; then
. "$HOME/.config/ash/profile"
fi
}}
Next create the file {{path|~/.config/ash/profile}} as follows:
{{Cat|~/.config/ash/profile|export ENV{{=}}"$HOME/.config/ash/ashrc"
}}
Now aliases can be added in the file {{Path|~/.config/ash/ashrc}}:


{{Cat|~/.config/ash/ashrc|su{{=}}"doas -s"
== Ash shell ==
}}
 
Alpine Linux uses Busybox [[Shell_management#Ash_shell|Ash shell]] for its default shell.


== vi ==
== vi ==
Line 28: Line 52:
Busybox uses [https://git.busybox.net/busybox/plain/editors/vi.c tiny vi], a small 'vi' clone. Refer [http://k.japko.eu/busybox-vi-tutorial.html Busybox vi tutorial] for an excellent introduction.  
Busybox uses [https://git.busybox.net/busybox/plain/editors/vi.c tiny vi], a small 'vi' clone. Refer [http://k.japko.eu/busybox-vi-tutorial.html Busybox vi tutorial] for an excellent introduction.  


== Replacing BusyBox Utilities==
== udhcpc ==
{{Main|How to get regular stuff working}}
 
The utilities in BusyBox generally have fewer options than their full-featured GNU counterparts. If you find certain utilities in busybox lacking in features or options, it is easy to [[How to get regular stuff working|replace]] respective endpoints by their equivalent full-featured utilities.
[[udhcpc]] is the default DHCP client that comes inbuilt with  Busybox.
 
== Cron ==
 
[[Cron#Busybox_crond|Busybox crond]] is the default cron implementation in Alpine Linux.
 
== acpid ==
 
Alpine Linux comes inbuilt with a basic version of [[Power_management#Busybox acpid|acpid]] as part of BusyBox.
 
== init ==
 
Busybox init is the first process(pid 1) started during boot. It never exits. It executes [[OpenRC]] runlevel scripts according to entries in {{Path|/etc/inittab}}.
 
== Shutdown commands ==
 
The busybox command equivalent for traditional GNU/Linux systems shutdown commands are as follows:{{Cmd|<nowiki># reboot  # ⇔ shutdown now -r
# halt    # ⇔ shutdown now -H
# poweroff # ⇔ shutdown now -P</nowiki>}}
 
== See also ==


== See Also ==
* [https://www.busybox.net/ Official website]
* [https://www.busybox.net/ Official website]
* [https://busybox.net/downloads/BusyBox.html Official BusyBox Manual]
* [https://busybox.net/downloads/BusyBox.html Official BusyBox Manual]
* [http://k.japko.eu/busybox-vi-tutorial.html Busybox vi tutorial]
* [http://k.japko.eu/busybox-vi-tutorial.html Busybox vi tutorial]
[[Category:System Administration]]
[[Category:System Administration]]

Latest revision as of 04:14, 16 October 2025

Alpine Linux is built around musl libc and busybox. To minimize footprint, Alpine Linux comes with BusyBox by default.

BusyBox provides replacements for most of the utilities usually found in GNU coreutils, util-linux, etc. Built-in utility programs called as applets share code for many common operations. BusyBox is set up as an endpoint for numerous symlinks that substitute various utilities. The utilities in BusyBox generally have fewer options than their full-featured GNU counterparts.

BusyBox applets

The command $ busybox lists the applets that have been compiled into BusyBox binary, the output of which, as of v3.22, is shown below:

$ busybox BusyBox v1.37.0 (2025-08-05 16:40:33 UTC) multi-call binary. BusyBox is copyrighted by many authors between 1998-2015. Licensed under GPLv2. See source distribution for detailed copyright notices. Usage: busybox [function [arguments]...] or: busybox --list[-full] or: busybox --install [-s] [DIR] or: function [arguments]... BusyBox is a multi-call binary that combines many common Unix utilities into a single executable. Most people will create a link to busybox for each function they wish to use and BusyBox will act like whatever it was invoked as. Currently defined functions: [, [[, acpid, add-shell, addgroup, adduser, adjtimex, arch, arp, arping, ash, awk, base64, basename, bbconfig, bc, beep, blkdiscard, blkid, blockdev, brctl, bunzip2, bzcat, bzip2, cal, cat, chattr, chgrp, chmod, chown, chpasswd, chroot, chvt, cksum, clear, cmp, comm, cp, cpio, crond, crontab, cryptpw, cut, date, dc, dd, deallocvt, delgroup, deluser, depmod, df, diff, dirname, dmesg, dnsdomainname, dos2unix, du, dumpkmap, echo, egrep, eject, env, ether-wake, expand, expr, factor, fallocate, false, fatattr, fbset, fbsplash, fdflush, fdisk, fgrep, find, findfs, flock, fold, free, fsck, fstrim, fsync, fuser, getopt, getty, grep, groups, gunzip, gzip, halt, hd, head, hexdump, hostid, hostname, hwclock, id, ifconfig, ifdown, ifenslave, ifup, init, inotifyd, insmod, install, ionice, iostat, ip, ipaddr, ipcalc, ipcrm, ipcs, iplink, ipneigh, iproute, iprule, iptunnel, kbd_mode, kill, killall, killall5, klogd, last, less, link, linux32, linux64, ln, loadfont, loadkmap, logger, login, logread, losetup, ls, lsattr, lsmod, lsof, lsusb, lzcat, lzma, lzop, lzopcat, makemime, md5sum, mdev, mesg, microcom, mkdir, mkdosfs, mkfifo, mkfs.vfat, mknod, mkpasswd, mkswap, mktemp, modinfo, modprobe, more, mount, mountpoint, mpstat, mv, nameif, nanddump, nandwrite, nbd-client, nc, netstat, nice, nl, nmeter, nohup, nologin, nproc, nsenter, nslookup, ntpd, od, openvt, partprobe, passwd, paste, pgrep, pidof, ping, ping6, pipe_progress, pivot_root, pkill, pmap, poweroff, printenv, printf, ps, pscan, pstree, pwd, pwdx, raidautorun, rdate, rdev, readahead, readlink, realpath, reboot, reformime, remove-shell, renice, reset, resize, rev, rfkill, rm, rmdir, rmmod, route, run-parts, sed, sendmail, seq, setconsole, setfont, setkeycodes, setlogcons, setpriv, setserial, setsid, sh, sha1sum, sha256sum, sha3sum, sha512sum, showkey, shred, shuf, slattach, sleep, sort, split, stat, strings, stty, su, sum, swapoff, swapon, switch_root, sync, sysctl, syslogd, tac, tail, tar, tee, test, time, timeout, top, touch, tr, traceroute, traceroute6, tree, true, truncate, tty, ttysize, tunctl, udhcpc, udhcpc6, umount, uname, unexpand, uniq, unix2dos, unlink, unlzma, unlzop, unshare, unxz, unzip, uptime, usleep, uudecode, uuencode, vconfig, vi, vlock, volname, watch, watchdog, wc, wget, which, who, whoami, whois, xargs, xxd, xzcat, yes, zcat, zcip

To view options supported by a specific BusyBox applet, say grep, issue the command $ busybox grep -h

Replacing BusyBox utilities

If you find certain utilities in busybox lacking in features or options, equivalent full-featured utilities can easily replace them. This may be particularly useful when intially setting up hardware like sound, networking, graphics and printers and can be removed once done.

Ash shell

Alpine Linux uses Busybox Ash shell for its default shell.

vi

Busybox uses tiny vi, a small 'vi' clone. Refer Busybox vi tutorial for an excellent introduction.

udhcpc

udhcpc is the default DHCP client that comes inbuilt with Busybox.

Cron

Busybox crond is the default cron implementation in Alpine Linux.

acpid

Alpine Linux comes inbuilt with a basic version of acpid as part of BusyBox.

init

Busybox init is the first process(pid 1) started during boot. It never exits. It executes OpenRC runlevel scripts according to entries in /etc/inittab.

Shutdown commands

The busybox command equivalent for traditional GNU/Linux systems shutdown commands are as follows:

# reboot # ⇔ shutdown now -r # halt # ⇔ shutdown now -H # poweroff # ⇔ shutdown now -P

See also