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¶
This is equivalent to booting into a server environment without a graphical interface.Example: Switch to Graphical Target¶
This activates a desktop environment (e.g., GNOME, KDE) by starting services likegdm.service or lightdm.service.
Check Current Default Target¶
Output might showmulti-user.target (default for servers) or graphical.target (default for desktops).
Set a New Default Target¶
This changes the default target for future boots. Usegraphical.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¶
This ensuresnginx starts when multi-user.target is active.
Disable a Service¶
Preventssshd from starting in multi-user mode.
Verify Active Services¶
Filters services active in the current target.Troubleshooting Target Switches¶
- Service Conflicts: If a service fails to start after switching targets, check its dependencies:
- Target Not Found: Ensure the target exists (e.g.,
graphical.targetrequires a desktop environment like GNOME). - Persistent Changes: Use
set-defaultto ensure the target persists across reboots.
Key takeaways¶
- Use
systemctl isolateto switch between targets, which control service states. multi-user.targetis optimal for servers, whilegraphical.targetis for desktops.- Customize multi-user environments by enabling/disabling services.
- Always verify target dependencies and use
set-defaultfor persistent configuration.