How to switch the run level

  
under CentOS7

The command to switch from the command line level to the window level has not changed: init 5 or startx

The command to switch from window level to command line level has not changed: init 3

The new version of the runlevel is defined under /lib/systemd/system:

[root@localhost ~]# ls -ltr /lib/systemd/system/runlevel*.target

lrwxrwxrwx. 1 root root 16 September 10 20:58 /lib/systemd/system/default.target -> graphical.target

lrwxrwxrwx. 1 root root 13 September 10 20:58 /Lib/systemd/system/runlevel1.target -> rescue.target

lrwxrwxrwx. 1 root root 15 September 10 20:58 /lib/systemd/system/runlevel0.target -> poweroff.target< Br>

lrwxrwxrwx. 1 root root 17 September 10 20:58 /lib/systemd/system/runlevel4.target -> multi-user.target

lrwxrwxrwx. 1 root root 17 September 10 20:58 /lib/systemd/system/runlevel3.target -> multi-user.target

lrwxrwxrwx. 1 root Root 17 September 10 20:58 /lib/systemd/system/runlevel2.target -> multi-user.target

lrwxrwxrwx. 1 root root 16 September 10 20:58 /lib/systemd/system /runlevel5.target -> graphical.target

lrwxrwxrwx. 1 root root 13 September 10 20:58 /lib/systemd/system/runlevel6.target -> reboot.target

You can set different run levels for different needs:

If you set the command line level (init 3) method:

[root@localhost ~]# ln -svf /lib/systemd/system/Runlevel3.target /etc/systemd/system/default.target

or

[root@localhost ~]# ln -svf /lib/systemd/system/multi-user.target /etc /systemd/system/default.target

or

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

Set window level (init 5) Method:

[root@localhost ~]# ln -svf /lib/systemd/system/runlevel5.target /etc/systemd/system/default.target

or

[root@localhost ~]# ln -svf /lib/systemd/system/gr Aphical.target /etc/systemd/system/default.target

or

[root@localhost ~]#systemctl set-default graphical.target

---- -------------------------Dividing line----------------------- ------

Modify the system runlevel:

1. Systemd uses a more free target instead of sysvinit's runlevel. The third run level is replaced with multi-user.target. The fifth run level is replaced by graphical.target. Runlevel3.target and runlevel5.target are symbolic links to multi-user.target and graphical.target, respectively.

You can use the following command to switch to “run level 3 ”:

systemctl isolate multi-user.target or systemctl isolate runlevel3.target

Command switch to “Runlevel 5 ”:

systemctl isolate graphical.target or systemctl isolate runlevel5.target

2. How to change the default runlevel?

systemd Link to point to the default run level. Before creating a new link, you can delete the existing link by the following command: rm /etc/systemd/system/default.target

Default boot runlevel 3 :

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

The default startup runlevel is 5:

ln -sf /lib/systemd/system/graphical. Target/etc/systemd/system/default.target

systemd does not use the /etc/inittab file.

-----------------------------Segmentation line ------------- ----------------

How do I view the current runlevel?

The old runlevel command can still be used under systemd. You can continue to use it, although systemd replaces the runlevel of the previous system with the ‘target’ concept (multiple ‘target’ can be activated at the same time).

The equivalent systemd command is systemctl list-units –type=target

Copyright © Windows knowledge All Rights Reserved