Skip to main content

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:

LevelDescriptionUsage
0HaltSystem shutdown
1Single-userMaintenance mode
2Multi-userMulti-user without network
3Multi-user + NetworkMulti-user with network
4Not usedCustomizable
5GraphicalGraphical mode (X11)
6RebootReboot

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 Runlevelsystemd TargetDescription
0poweroff.targetShutdown
1rescue.targetRescue mode
2, 3, 4multi-user.targetMulti-user
5graphical.targetGraphical mode
6reboot.targetReboot

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 single or 1 to 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