How to use systemd targets and runlevels

· Category: Linux

Short answer

Systemd targets replace traditional runlevels, grouping units that should be started together.

Steps

  1. View default target:
systemctl get-default
  1. List available targets:
systemctl list-units --type=target
  1. Change default target:
sudo systemctl set-default multi-user.target
  1. Switch target immediately:
sudo systemctl isolate graphical.target

Tips

  • multi-user.target is like runlevel 3 (text mode).
  • graphical.target is like runlevel 5 (GUI).
  • rescue.target and emergency.target are for troubleshooting.

Common issues

  • Switching targets stops services not included in the new target.
  • Custom targets can be created for specialized system states.