7. init
When the Linux kernel finishes booting, it runs an executable as the first and only userland process. This executable is called the init
program.
The init process is then responsible for setting up the entire userland (or destroying everything when you want to have fun).
This typically means reading some configuration files (e.g. /etc/initrc
) and forking a bunch of userland executables based on those files, including the very interactive shell that we end up on.
systemd provides a "popular" init implementation for desktop distros as of 2017.
BusyBox provides its own minimalistic init implementation which Buildroot, and therefore this repo, uses by default.
The init
program can be either an executable shell text file, or a compiled ELF file. It becomes easy to accept this once you see that the exec
system call handles both cases equally: https://unix.stackexchange.com/questions/174062/can-the-init-process-be-a-shell-script-in-linux/395375#395375
The init
executable is searched for in a list of paths in the root filesystem, including /init
, /sbin/init
and a few others. For more details see: Section 7.3, “Path to init”