Docs / Linux Basics / Understanding Linux Runlevels and systemd Targets

Understanding Linux Runlevels and systemd Targets

By Admin · Mar 15, 2026 · Updated Apr 24, 2026 · 196 views · 3 min read

Linux runlevels (SysV init) and systemd targets define the state of the system — which services are running and what functionality is available. Understanding these concepts helps you manage server boot behavior and troubleshoot startup issues.

Traditional Runlevels (SysV init)

# Classic runlevels:
# 0 — Halt (shutdown)
# 1 — Single-user mode (rescue/recovery)
# 2 — Multi-user without networking (Debian: multi-user with networking)
# 3 — Multi-user with networking (typical server)
# 4 — Unused (custom)
# 5 — Multi-user with GUI
# 6 — Reboot

systemd Targets

systemd targets replaced runlevels with a more flexible dependency-based system.

# Key systemd targets:
# poweroff.target       — Runlevel 0 (shutdown)
# rescue.target         — Runlevel 1 (single-user, minimal services)
# multi-user.target     — Runlevel 3 (text-mode, all services, no GUI)
# graphical.target      — Runlevel 5 (GUI login)
# reboot.target         — Runlevel 6 (reboot)
# emergency.target      — Minimal boot (even fewer services than rescue)

# Check current default target
systemctl get-default
# multi-user.target (typical for servers)

# Set default target
sudo systemctl set-default multi-user.target

# Switch targets at runtime (like changing runlevels)
sudo systemctl isolate rescue.target     # Enter rescue mode
sudo systemctl isolate multi-user.target # Return to normal

Working with Targets

# List all available targets
systemctl list-unit-files --type=target

# List active targets
systemctl list-units --type=target

# See what services a target includes
systemctl list-dependencies multi-user.target

# See the dependency tree
systemctl list-dependencies multi-user.target --all

Custom Targets

# Create a custom target for maintenance mode
sudo cat > /etc/systemd/system/maintenance.target << EOF
[Unit]
Description=Maintenance Mode
Requires=basic.target
Conflicts=rescue.target
After=basic.target
AllowIsolate=yes
EOF

# Assign a service to your custom target
sudo systemctl edit myapp.service
# [Install]
# WantedBy=maintenance.target

sudo systemctl daemon-reload

Rescue and Emergency Modes

# Rescue mode: single-user with basic services (filesystems mounted)
# Enter from running system:
sudo systemctl isolate rescue.target

# Emergency mode: absolute minimum (root filesystem read-only)
sudo systemctl isolate emergency.target

# From GRUB menu during boot:
# Edit the kernel line and add:
# systemd.unit=rescue.target
# or
# systemd.unit=emergency.target

Managing Services Per Target

# Enable a service to start at boot (multi-user.target)
sudo systemctl enable nginx

# Disable a service from starting at boot
sudo systemctl disable nginx

# Check which target a service belongs to
systemctl show nginx.service | grep WantedBy

# Enable a service only for a specific target
sudo systemctl enable myservice.service --no-reload
# The [Install] WantedBy= section in the unit file determines this

Troubleshooting Boot Targets

# If system boots to wrong target (e.g., emergency mode)
# 1. Check for failed services
systemctl --failed

# 2. Check fstab for errors (common cause of emergency mode)
cat /etc/fstab
sudo findmnt --verify

# 3. Check disk health
sudo fsck /dev/vda1

# 4. View boot logs
journalctl -b -p err

Runlevel Compatibility

# systemd provides backward compatibility
# These commands still work:
runlevel              # Show current and previous runlevel
who -r                # Show current runlevel
telinit 3             # Switch to runlevel 3 (multi-user.target)

# systemd maps old runlevels to targets
ls -la /usr/lib/systemd/system/runlevel*.target
# runlevel0.target -> poweroff.target
# runlevel1.target -> rescue.target
# runlevel3.target -> multi-user.target
# runlevel5.target -> graphical.target
# runlevel6.target -> reboot.target

Was this article helpful?