In CentOS, the systemd is the default initialization system that uses the concept of runlevels, which are known as targets. Changing the runlevels is important because it allows users to control which services and daemons are running on the system. This can help reduce the load on the system and improve its overall performance.
This article will illustrate the step-by-step procedure to change the runlevels (targets) with systemd in CentOS.
- How to Change runlevels (targets) With the systemd in CentOS?
- Check the current runlevels (targets)
- List all Available targets
- Change the Default target
- Reboot the System
- Bonus Tip: Switch to a Different target
How to Change runlevels (targets) With systemd in CentOS?
To change the runlevels (targets) in CentOS/RHEL, follow the steps below:
Step 1: Check the Current runlevels (targets)
To check the current runlevels (targets), use the “systemctl” command with the “get-default” utility as below:
# systemctl get-default
The output displays the default target “graphical.target”, which is currently in use in the operating system.
Step 2: List All Available targets
To list all the available targets, use the “systemctl” command by specifying the “list-units” utility and assigning target value to “type”:
# systemctl list-units --type=target
This command displays a list of all available targets along with the description in the listed format.
Step 3: Change the Default target
To change the default target, use the “systemctl” command with the “set-default” utility. The basic syntax is provided below:
# systemctl set-default <target>
In the above syntax, replace “<target>” with the target that users want to use. For instance, change the default target to “sound.target” by executing the following command:
# systemctl set-default sound.target
The output shows that “sound.target” has been changed with the “systemctl” command.
Step 4: Reboot the System
After changing the default target, reboot the system to apply the changes. To do so, use the following command to reboot the system:
After executing the above command, the system reboots and starts in the new default target.
How to Switch to a Different Target in CentOS?
Alternatively, users can switch to a different target without changing the default target to isolate the issue. For example, the graphical.target provides a graphical user interface, local-fs.target assists the local file system, etc.
To switch to a different target, follow the below syntax:
# systemctl isolate <target>
In the above syntax, replace “<target>” with the target that users want to use. To get all runlevels (targets) with the systemd, execute the “systemctl list-units –type=target” command just as in step 2.
For instance, to switch to the “graphical.target” without changing the default target, use the following command:
# systemctl isolate graphical.target
This command immediately switches to the “graphical.target” without changing the default target.
To change the runlevels (targets) with the systemd in CentOS, use the “systemctl set-default <target>” command. Users can visualize the list of all available targets by executing the “systemctl list-units –type=target” command. After changing the specified targets, verify it via the “systemctl get-default” command in CentOS.
This guide has demonstrated the step-by-step instructions to change the runlevels (targets) with systemd in CentOS.