How to Change Runlevels (targets) in SystemD?

SystemD is a system and service manager for Linux operating systems that manages the boot process, system services, and provides a centralized way to manage processes. One of its key features is the use of targets (the modern equivalent of runlevels) to define different system states and control which services run during startup and operation.

Understanding how to change targets is essential for Linux administrators as it allows precise control over system behavior, resource usage, and available services based on specific operational requirements.

Understanding SystemD Targets

SystemD replaces traditional Unix runlevels with targets, which are more flexible units that define groups of services and system states. Unlike the rigid numeric runlevel system, targets can have complex dependencies and can be combined to create sophisticated system configurations.

Targets serve two primary purposes

  • Provide an organized way to manage related services as logical groups

  • Define system states and service dependencies for consistent boot behavior

Common SystemD Targets

Target Traditional Runlevel Description
poweroff.target 0 System shutdown
rescue.target 1 Single-user rescue mode
multi-user.target 3 Multi-user text mode with networking
graphical.target 5 Multi-user mode with GUI
reboot.target 6 System restart

Changing Targets

Identifying Current Target

Before changing targets, identify the current system state using these commands

systemctl get-default

This displays the default target. To see all currently active targets

systemctl list-units --type=target

Temporary Target Changes

To switch to a target immediately without changing the default boot target

sudo systemctl isolate target_name.target

Example switching to text mode temporarily

sudo systemctl isolate multi-user.target

Permanent Target Changes

To set a new default target that persists across reboots

sudo systemctl set-default target_name.target

Example setting graphical mode as default

sudo systemctl set-default graphical.target

Verify the change with

systemctl get-default

Advanced Techniques

Using Symbolic Links

SystemD targets can also be managed through symbolic links. The default target is actually a symlink at /etc/systemd/system/default.target.

sudo ln -sf /usr/lib/systemd/system/multi-user.target /etc/systemd/system/default.target

Viewing Available Targets

List all available targets on the system

systemctl list-unit-files --type=target

Troubleshooting Common Issues

Permission Errors

Ensure you use sudo for administrative commands. Target changes require root privileges to modify system configuration files and service states.

Service Dependencies

Some services may fail to start if their dependencies aren't met in the new target. Check service status and dependencies

systemctl status service_name
systemctl list-dependencies target_name.target

Syntax Errors

Verify command syntax and target names. Use tab completion to ensure correct target names, and always include the .target suffix when specifying targets.

Conclusion

SystemD targets provide flexible system state management, replacing traditional runlevels with a more powerful dependency-based system. Mastering target switching both temporary and permanent enables administrators to optimize system resources and control service availability based on operational needs.

Updated on: 2026-03-17T09:01:39+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements