In this lesson, we’ll cover how to manage runlevels with SysV init, configure boot targets, and perform system shutdown or reboot. Controlling which services start or stop is essential for Linux administration—whether you’re running web servers, mail daemons, or network services.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
SysV init and Runlevels
On SysV-based systems,/sbin/init (PID 1) manages services through predefined runlevels (0–6). Each runlevel corresponds to a different system state:
| Runlevel | Description |
|---|---|
| 0 | Halt (shutdown) |
| 1, S | Single-user mode (no networking), maintenance |
| 2 | Multi-user mode without NFS (custom on some distros) |
| 3 | Full multi-user mode with networking (console login) |
| 4 | Unused/reserved (user-defined) |
| 5 | Graphical multi-user mode (desktop environment) |
| 6 | Reboot |

/etc/inittab: Specifies which scripts or processes to start at each runlevel/etc/init.d/: Contains the actual service scripts
Common /etc/inittab Actions
| Action | Description |
|---|---|
| sysinit | Run once during system initialization (ignores runlevels) |
| boot | Run at boot time, but init does not wait for completion (ignores runlevels) |
| bootwait | Run at boot time—init waits until it finishes (ignores runlevels) |
| wait | Run when entering listed runlevels—init waits for it to complete |
| respawn | Always restart the process if it terminates |
| ctrlaltdel | Triggered on SIGINT (CTRL+ALT+DEL) |
| initdefault | Sets the default runlevel (values 1–5, not 0 or 6) |

Editing /etc/inittab
Before making changes, back up the file:
After editing
/etc/inittab, reload init’s configuration without rebooting:Init Scripts and Service Directories
Service scripts live in/etc/init.d/, while each runlevel directory in /etc/rc*.d/ contains symlinks:
rcN.d directory, file prefixes determine actions:
| Prefix | Operation |
|---|---|
| Snn | Start service when entering N |
| Knn | Stop service when entering N |
Checking and Changing Runlevels
- Show current and previous runlevels:
- Switch to single-user mode (runlevel 1):
- Reboot using runlevel 6:
- Halt using runlevel 0:
Switching runlevels will start or stop multiple services. Always save your work and notify other users before changing to runlevels 0, 1, or 6.