LinuxCommandLibrary

init

Start the Linux operating system processes

TLDR

Set the system to run a graphical environment

$ sudo init 5
copy

Set the system to run multiuser terminal
$ sudo init 3
copy

Shut down the system
$ init 0
copy

Reboot the system
$ init 6
copy

Set the system to run on terminal with only root user allowed and no networking
$ sudo init 1
copy

SYNOPSIS

init [options] [runlevel]

PARAMETERS

-a
    Process /etc/inittab entries for sysinit, boot, bootwait actions, and unknown keys

-s
    Enter single-user mode immediately

-q
    Rescan /etc/inittab and enqueue changes without runlevel switch

-t secs
    Set timeout between respawn checks (default 20-30s)

runlevel
    Switch to runlevel: 0(halt),1(single-user),2-5(multi-user),6(reboot),S(single),Q(re-examine)

DESCRIPTION

The init command, executed as PID 1 by the kernel during boot, is the ancestor of every other process in a Linux system. It initializes the system by mounting filesystems, starting core services, and transitioning through runlevels based on configuration. In traditional SysV init, it parses /etc/inittab to define actions for respawning processes, handling signals, and managing system states like single-user or multi-user mode.

Modern distributions often replace SysV init with systemd (which symlinks to /lib/systemd/systemd), Upstart, or others, but the interface remains /sbin/init. Init handles system shutdown gracefully when exiting, terminating children.

Direct use is rare and risky outside boot; it controls power states, logging, and process supervision. Signals like SIGTERM trigger runlevel changes. For runtime control, use telinit or systemctl. Init ensures system reliability by restarting failed services defined in its config.

CAVEATS

Do not invoke init manually except in emergencies; it risks system lockup or data loss. Use telinit(8) or systemctl(1) for runlevel/target changes. Behavior varies by init implementation (SysV vs systemd).

RUNLEVELS (SYSV)

0: Halt/poweroff
1/S: Single-user
2: Multi-user (no NFS)
3: Full multi-user (default)
4: Custom
5: GUI/multi-user
6: Reboot

SYSTEMD EQUIVALENTS

Targets replace runlevels: default.target (~3), graphical.target (~5), rescue.target (~1). Use systemctl isolate.

HISTORY

Introduced in Unix Version 7 (1979), evolved in System III/V (1980s) with runlevels in SVR3 (1988). SysV init standardized until 2000s. Ubuntu adopted Upstart (2006), Fedora/RHEL systemd (2011+), now dominant for parallelization and cgroups support.

SEE ALSO

telinit(8), systemd(1), shutdown(8), halt(8), runlevel(8), inittab(5)

Copied to clipboard