Skip to content

Multi-User Envs

Systemd replaces traditional init system runlevels with targets, which are abstract groupings of services. While runlevels (e.g., runlevel 3) were used in SysV init, systemd uses targets like multi-user.target (server-focused) and graphical.target (desktop environment). Managing these targets allows administrators to control service states and environment configurations effectively.


Switching Between Targets

To switch between targets, use systemctl isolate [TARGET]. This command stops all services from the previous target and starts those defined in the new target.

Example: Switch to Multi-User Target

sudo systemctl isolate multi-user.target
This is equivalent to booting into a server environment without a graphical interface.

Example: Switch to Graphical Target

sudo systemctl isolate graphical.target
This activates a desktop environment (e.g., GNOME, KDE) by starting services like gdm.service or lightdm.service.

Check Current Default Target

systemctl get-default
Output might show multi-user.target (default for servers) or graphical.target (default for desktops).

Set a New Default Target

sudo systemctl set-default multi-user.target
This changes the default target for future boots. Use graphical.target for desktop environments.


Configuring Multi-User Environments

The multi-user.target is ideal for headless servers. However, you can customize it by enabling/disabling services:

Enable a Service for Multi-User

sudo systemctl enable nginx.service
This ensures nginx starts when multi-user.target is active.

Disable a Service

sudo systemctl disable sshd.service
Prevents sshd from starting in multi-user mode.

Verify Active Services

systemctl list-units --type=service --state=active
Filters services active in the current target.


Troubleshooting Target Switches

  • Service Conflicts: If a service fails to start after switching targets, check its dependencies:
    systemctl status [SERVICE]
    
  • Target Not Found: Ensure the target exists (e.g., graphical.target requires a desktop environment like GNOME).
  • Persistent Changes: Use set-default to ensure the target persists across reboots.

Key takeaways

  • Use systemctl isolate to switch between targets, which control service states.
  • multi-user.target is optimal for servers, while graphical.target is for desktops.
  • Customize multi-user environments by enabling/disabling services.
  • Always verify target dependencies and use set-default for persistent configuration.