Introduction
Hey there, readers! Welcome to our comprehensive guide on mastering the art of changing runlevels and targets using systemd in Ubuntu. Get ready to dive into the world of system initialization and unleash the full potential of your Ubuntu system.
Systemd is a powerful system and service manager that has revolutionized the way system initialization is handled in Linux distributions, including Ubuntu. With systemd, you can effortlessly control the boot process, manage services, and switch between different operating modes, known as targets or runlevels.
Understanding Runlevels and Targets
What are Runlevels?
Runlevels are traditional operating modes in Unix-like systems that determine the state of the system after boot. Each runlevel represents a specific configuration of services and processes that are active or inactive. For instance, runlevel 0 represents the halt state, while runlevel 5 typically signifies a fully graphical user interface (GUI) environment.
Targets in systemd
In systemd, the concept of runlevels has been replaced by targets. Targets are more flexible and allow for finer-grained control over the system’s state. Each target defines a specific set of services and processes that should be running. For example, the “multi-user.target” target corresponds to the traditional runlevel 3 and starts a multi-user system with networking support.
Changing Runlevels/Targets
Using systemctl
The primary tool for managing runlevels and targets in systemd is the systemctl command. It provides a convenient way to query and modify the system’s state. To change the current target, simply use the following syntax:
systemctl isolate <target name>
For instance, to switch to the graphical target, you would run:
systemctl isolate graphical.target
Using the initctl Command (Legacy)
For systems that still use the legacy init system, the initctl command can be used to change runlevels. However, it’s recommended to use systemctl for consistency and compatibility with systemd.
initctl <runlevel>
For example, to switch to runlevel 3, you would run:
initctl 3
Using the GUI (Optional)
Many graphical user interface (GUI) tools provide options for changing runlevels or targets. These tools typically offer a user-friendly interface that simplifies the process for beginners.
Systemd Targets and Their Functions
Target Name | Description |
---|---|
rescue.target | Emergency mode |
shutdown.target | System shutdown |
poweroff.target | System power off |
reboot.target | System reboot |
user@.service | User-specific services |
graphical.target | Multi-user graphical target |
multi-user.target | Multi-user target without graphical interface |
emergency.target | Emergency mode |
maintenance.target | Maintenance mode |
Conclusion
Mastering the art of changing runlevels and targets using systemd in Ubuntu is a fundamental step towards understanding and controlling your system’s behavior. By leveraging the systemctl command or utilizing a graphical tool, you can effortlessly switch between different operating modes, manage services, and adapt your system to suit your specific needs.
Be sure to explore our other articles for even more in-depth insights into the fascinating world of Linux system administration.
How to troubleshoot “Failed to change runlevel or target using systemd”
How do I check the current runlevel or target?
systemctl get-default
How do I change the default runlevel or target?
systemctl set-default <runlevel or target>
How do I change the current runlevel or target?
systemctl start <runlevel or target>
How do I get more information about a specific runlevel or target?
systemctl status <runlevel or target>