Chapter 2.8 - Execution Levels (Runlevels)
Learning Objectives
By the end of this chapter, you will be able to:
- Understand runlevels
- Explain systemd targets
- Change execution levels
- Understand SysV/systemd correspondences
What is an Execution Level?
A runlevel defines which services are active on the system. It determines the state of the system after booting.
Traditional Runlevels (SysV)
Traditional system with 7 levels:
| Level | Description | Usage |
|---|---|---|
| 0 | Halt | System shutdown |
| 1 | Single-user | Maintenance mode |
| 2 | Multi-user | Multi-user without network |
| 3 | Multi-user + Network | Multi-user with network |
| 4 | Not used | Customizable |
| 5 | Graphical | Graphical mode (X11) |
| 6 | Reboot | Reboot |
systemd Targets (Modern)
systemd uses targets instead of runlevels:
Main targets:
poweroff.target(runlevel 0)rescue.target(runlevel 1)multi-user.target(runlevel 3)graphical.target(runlevel 5)reboot.target(runlevel 6)
SysV ↔ systemd Correspondences
| SysV Runlevel | systemd Target | Description |
|---|---|---|
| 0 | poweroff.target | Shutdown |
| 1 | rescue.target | Rescue mode |
| 2, 3, 4 | multi-user.target | Multi-user |
| 5 | graphical.target | Graphical mode |
| 6 | reboot.target | Reboot |
Commands
View Current Level
# Old system (SysV)
runlevel
# systemd
systemctl get-default
Change Level
# Old system
init 3
telinit 5
# systemd
systemctl isolate multi-user.target
systemctl isolate graphical.target
# Change default
sudo systemctl set-default multi-user.target
sudo systemctl set-default graphical.target
View Available Targets
systemctl list-units --type=target
systemctl list-units --type=target --all
Single User Mode (Rescue)
Single user mode (rescue) is used for:
- System maintenance
- System file repair
- Root password reset
- Recovery after issues
Access:
- Grub: add
singleor1to the kernel - systemd:
systemctl rescue
Summary
In this chapter, you learned:
Runlevels: System execution levels
SysV: 7 levels (0-6)
systemd: Targets (poweroff, rescue, multi-user, graphical, reboot)
Correspondences: Mapping between SysV and systemd
Change: systemctl isolate, systemctl set-default
Rescue: Maintenance and repair mode
Next Steps
Chapter 2.9: Boot Process
Chapter 2.10: Inter-Process Communication
Chapter created on: December 2024