BusyBox: Difference between revisions

From Alpine Linux
(added more info on busybox)
(moved Shutdown commands from OpenRC page)
 
(11 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]. BusyBox provides replacements for most of the utilities usually found in GNU coreutils, util-linux, etc. The utilities in BusyBox generally have fewer options than their full-featured GNU counterparts.
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. To list the applets that have been compiled into BusyBox binary, issue the command with no argument as follows: {{ic|$ busybox}}


BusyBox is a multi-call binary. A multi-call binary is an executable program that performs the same job as more than one utility program. That means there is just a single BusyBox binary, but that single binary acts like a large number of utilities. This allows BusyBox to be smaller since all the built-in utility programs (called as applets) can share code for many common operations.  Invoking BusyBox with no arguments, will provide with a list of the applets that have been compiled into BusyBox binary.
To view options supported by a specific BusyBox applet, say {{ic|grep}}, issue the command {{ic|$ busybox grep -h}}


Refer [https://busybox.net/downloads/BusyBox.html BusyBox Manual] for options supported by BusyBox.
== Ash shell ==


== Ash shell ==
Alpine Linux uses Busybox [[Shell_management#Ash_shell|Ash shell]] for its default shell.
 
== vi ==
 
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.
 
== udhcpc ==


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]].
[[udhcpc]] is the default DHCP client that comes inbuilt with  Busybox.


=== Aliases ===
== Cron ==


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.  
[[Cron#Busybox_crond|Busybox crond]] is the default cron implementation in Alpine Linux.


First create the file {{Path|/etc/profile.d/profile.sh}} as follows:
== acpid ==
{{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"
Alpine Linux comes inbuilt with a basic version of [[Power_management#Busybox acpid|acpid]] as part of BusyBox.  
}}


== Replacing BusyBox Utilities==
== Replacing BusyBox utilities==
{{Main|How to get regular stuff working}}
{{Main|How to get regular stuff working}}
If you find certain utilities in busybox lacking in features or options, it is easy to [[How to get regular stuff working|replace]] respective busybox endpoints by their equivalent full-featured utilities.
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. 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.
 
== 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]
[[Category:System Administration]]
[[Category:System Administration]]

Latest revision as of 04:17, 12 August 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. To list the applets that have been compiled into BusyBox binary, issue the command with no argument as follows: $ busybox

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

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.

Replacing BusyBox utilities

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. If you find certain utilities in busybox lacking in features or options, it is easy to replace respective endpoints by their equivalent full-featured utilities.

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