Loading...

Lab 115: Systemd Targets & Runlevels

Inspect the default systemd target, safely isolate between targets, and verify persistent defaults via the default.target symlink. Confirm active targets and runlevel-style mappings so you can reason about boot behavior and operational mode changes without rebooting.

troubleshooting boot core

Scenario

A host is booting into an unexpected mode and services are not behaving as the team expects. Before changing anything, you need to confirm the current default systemd target, understand what targets are currently active, and practice switching between targets safely using isolate. You will then set a persistent default and verify it using the /etc/systemd/system/default.target symlink.

Operator context

Changing targets can stop services and terminate sessions. Do target changes as controlled operations and always verify the active and persistent state separately.

Objective

  • Display the current default systemd target and interpret what it means.
  • List active targets to understand current system mode.
  • Temporarily isolate to multi-user.target without changing the default.
  • Verify that multi-user.target is active.
  • Set multi-user.target as the persistent default.
  • Inspect the default.target symlink to prove the persistent default.
  • Restore graphical.target as the persistent default and verify the symlink update.
  • Isolate back to graphical.target for the current session.
  • Show a runlevel-style view and relate it back to targets.

Concepts

  • Targets are “state bundles” that pull in groups of services and dependencies.
  • The default target affects the next boot. Active targets describe what is running now.
  • systemctl isolate changes current state immediately and may stop non-required units.
  • systemctl set-default updates the /etc/systemd/system/default.target symlink.
  • Runlevels are legacy terminology. On systemd systems they map to targets, but targets are the source of truth.

Walkthrough

Step 1 : Show the current default systemd target.
Command
systemctl get-default

This is the target the system will boot into by default. It does not necessarily reflect the mode you are currently in if someone isolated into a different target during runtime.

graphical.target
Step 2 : List currently active targets (first 10 lines).
Command
systemctl list-units --type=target --state=active | head -n 10

Active targets give you an operational snapshot. Multiple targets can be active because they represent dependency groupings.

UNIT                  LOAD   ACTIVE SUB    DESCRIPTION
basic.target          loaded active active Basic System
sockets.target        loaded active active Sockets
multi-user.target     loaded active active Multi-User System
graphical.target      loaded active active Graphical Interface
timers.target         loaded active active Timers
Step 3 : Isolate to multi-user mode without changing the default.
Safety note

Isolating to multi-user.target can stop graphical services and terminate graphical sessions. Use this intentionally.

Command
systemctl isolate multi-user.target

isolate switches the current system state by stopping units not required by the target and starting what is needed to reach it. This does not change the default boot target.

(switched to multi-user.target; graphical sessions would stop if present)
Step 4 : Verify multi-user.target is active.
Command
systemctl list-units --type=target --state=active | grep multi-user.target

Confirm state instead of assuming the isolate succeeded just because the command returned.

multi-user.target     loaded active active Multi-User System
Step 5 : Set multi-user as the persistent default target.
Command
systemctl set-default multi-user.target

This changes what the system will boot into on the next reboot by updating the default.target symlink.

Created symlink /etc/systemd/system/default.target → /lib/systemd/system/multi-user.target
Step 6 : Inspect the default.target symlink destination.
Command
ls -l /etc/systemd/system/default.target

This is the durable proof of the persistent default. When troubleshooting “why did it boot into text mode,” this symlink is a primary artifact to check.

lrwxrwxrwx 1 root root 46 Aug 19 12:40 /etc/systemd/system/default.target -> /lib/systemd/system/multi-user.target
Step 7 : Restore graphical as the persistent default target.
Command
systemctl set-default graphical.target

This returns the system to a graphical boot default for the next reboot.

Removed symlink /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /lib/systemd/system/graphical.target
Step 8 : Confirm the symlink now points to graphical.target.
Command
ls -l /etc/systemd/system/default.target

Confirming the symlink destination ensures the persistent default target is what you intend.

lrwxrwxrwx 1 root root 45 Aug 19 12:42 /etc/systemd/system/default.target -> /lib/systemd/system/graphical.target
Step 9 : Isolate back to graphical for the current session.
Safety note

Isolating into graphical.target will start graphical services and may change system resource usage.

Command
systemctl isolate graphical.target

This changes the current running state immediately. It is separate from set-default, which controls only future boots.

(switched to graphical.target)
Step 10 : Show the runlevel-style status.
Command
who -r
Command
runlevel

These commands provide a legacy-friendly view. Use them for quick context, then verify state using systemd tooling.

# who -r
run-level 5  2025-08-19 12:43                   last=3

# runlevel
N 5

Common breakpoints

isolate disconnects your session

That is expected when you stop a display manager or switch targets on a system you are connected to through a graphical login. Use an out-of-band console, a persistent TTY, or a controlled maintenance window when practicing isolate on non-lab hosts.

set-default changed, but the current mode did not

That is expected. set-default affects the next boot only. Use systemctl isolate if you want to change the current state.

runlevel output looks confusing

Runlevels are compatibility views. Use them as a hint and confirm real state using systemctl list-units --type=target --state=active and the default.target symlink.

Cleanup checklist

Leave the system in a known-good state by restoring the persistent default and confirming active targets.

Commands
systemctl set-default graphical.target
ls -l /etc/systemd/system/default.target
systemctl get-default
systemctl list-units --type=target --state=active | grep -E 'multi-user.target|graphical.target'
who -r
runlevel
Success signal

You can explain the difference between default and active targets, safely switch targets for the current session, and prove the persistent default by reading the symlink.

Reference

  • systemctl get-default : Displays the persistent default target used at boot.
  • systemctl list-units --type=target : Lists target units.
    • --state=active : Shows only active targets.
  • systemctl isolate <target> : Switches the current running state to the specified target.
  • systemctl set-default <target> : Sets the target used on the next boot by updating /etc/systemd/system/default.target.
  • /etc/systemd/system/default.target : Symlink that defines the default boot target.
  • graphical.target : Graphical boot target (typically includes multi-user plus a display manager).
  • multi-user.target : Multi-user text environment target.
  • who -r : Displays the current runlevel-style status.
  • runlevel : Prints previous and current runlevel (compatibility view).