CentOS 8 ways to change the run level

Time:2021-9-21

System D is a modern initialization system for Linux: a system service manager compatible with the popular SYSV initialization system and LSB initialization scripts.
On the Linux system, the current operating state of the operating system is called the running level; It defines the running system services. Systems before centos6 use SYSV init, and the operation level is identified by numbers. However, in SYSTEMd, the run level is called targets.

In this article, we will explain how to use SYSTEMd to change the run level (targets). Before proceeding, briefly describe the relationship between run level numbers and targets:

Level 0 matches poweroff.target, (runlevel 0.target is a symbolic link to poweroff.target).
Level 1 matches rescue.target, (runlevel 1.target is a symbolic link to rescue.target).
Level 3 is matched by multi-user.target, (runlevel 3.target is a symbolic link to multi-user.target).
Level 5 is matched by graphic.target, (runlevel 5.target is a symbolic link to graphic.target).
Level 6 is matched by reboot. Target (runlevel 6. Target is a symbolic link to reboot. Target).
Emergency matches emergency.target.
How to view the current targets (run level) in system D
When the system starts, SYSTEMd activates the default.target unit by default. Its main work is to activate services and other units through dependencies. To view the default target, enter the following command:

[[email protected] ~]# systemctl get-default
multi-user.target
Centos8 how to change the run level centos8 how to change the run level

How to set the default targets (run level) in system D
To set the default target, run the following command.

[[email protected] ~]# systemctl set-default graphical.target
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target.
Centos8 how to change the run level centos8 how to change the run level

Switch targets during system operation
When the system is running, you can switch targets (operation level), which means that only services and units defined under the target will run on the system.

To switch to run level 5 (graphical. Target), run the following command, provided the graphical interface is installed.

[[email protected] ~]# systemctl isolate runlevel5.target
perhaps
[[email protected] ~]# systemctl isolate graphical.target
After executing the command, you will immediately enter the graphical interface.
Centos8 how to change the run level centos8 how to change the run level
Centos8 how to change the run level centos8 how to change the run level

summary
This article summarizes and shows how to use SYSTEMd to change the running level (targets) in CentOS 8 systems.