How to change the run level in Centos8

Guide Systemd is a modern initialization system for Linux : a system service manager compatible with the popular SysV initialization system and LSB initialization scripts .

On Linux systems , the current operating state of the operating system is called the run level; it defines the system services that are running. In Centos use SysV init system before the 6 seed, run level identified by number. However, in systemd, the run level is called targets.

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

  • Level 0 matches poweroff.target , (runlevel0.target is a symbolic link to poweroff.target).
  • Level 1 matches rescue.target , (runlevel1.target is a symbolic link to rescue.target).
  • Level 3 is matched by multi-user.target , (runlevel3.target is a symbolic link to multi-user.target).
  • Level 5 is matched by graphic.target (runlevel5.target is a symbolic link to graphic.target).
  • Level 6 is matched by reboot.target (and runlevel6.target is a symbolic link to reboot.target).
  • Emergency matches emergency.target .

How to view the current targets (run level) in Systemd

When the system starts, by default, systemd activates the default.target unit. Its main job is to activate services and other units through dependencies. To view the default target, enter the following command :

[root@localhost ~]# systemctl get-default 
multi-user.target

How to change the run level in Centos 8 How to change the run level in Centos 8

How to set the default targets (run level) in Systemd

To set the default target, run the following command .

[root@localhost ~]# systemctl set-default graphical.target 
Removed /etc/systemd/system/default.target.
Created symlink /etc/systemd/system/default.target → /usr/lib/systemd/system/graphical.target.

How to change the run level in Centos 8 How to change the run level in Centos 8

Switch targets (run level) during system operation

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

To switch to run level 5 (graphical.target), run the following command, provided that the graphical interface has been installed.

[root@localhost ~]# systemctl isolate runlevel5.target 
或者
[root@localhost ~]# systemctl isolate graphical.target 

After executing the command, it will immediately enter the graphical interface.
How to change the run level in Centos 8 How to change the run level in Centos 8
How to change the run level in Centos 8 How to change the run level in Centos 8

to sum up

This article summarizes how to use systemd to change the run level (targets) in the Centos8 system. Linux should be learned like this

Guess you like

Origin blog.csdn.net/Linuxprobe18/article/details/111941862