Switch the running level under CentOS7

Source: Internet
Author: User
Commands switched from the command line level to the window level have not changed: init5 or startx commands switched from the window level to the command line level have not changed: the running level of the new version of init3 is defined under/lib/systemd/system: [root @ localhost ~] # Ls-ltr/lib/systemd/system/runlevel *. targetlrwxrwxrwx.1rootroo

Commands switched from the command line level to the window level have not changed: init 5 or startx

Commands switched from the window level to the command line level have not changed: init 3

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

[Root @ localhost ~] # Ls-ltr/lib/systemd/system/runlevel *. target
Lrwxrwxrwx. 1 root 16 September 10 20:58/lib/systemd/system/default.tar get-> graphical.tar get
Lrwxrwxrwx. 1 root 13 October 13 20:58/lib/systemd/system/runlevel1.target-> rescue.tar get
Lrwxrwxrwx. 1 root 15 Aug 17 20:58/lib/systemd/system/runlevel0.target-> poweroff.tar get
Lrwxrwxrwx. 1 root 17 September 10 20:58/lib/systemd/system/runlevel4.target-> multi-user.target
Lrwxrwxrwx. 1 root 17 September 10 20:58/lib/systemd/system/runlevel3.target-> multi-user.target
Lrwxrwxrwx. 1 root 17 September 10 20:58/lib/systemd/system/runlevel2.target-> multi-user.target
Lrwxrwxrwx. 1 root 16 September 10 20:58/lib/systemd/system/runlevel5.target-> graphical.tar get
Lrwxrwxrwx. 1 root 13 October 13 20:58/lib/systemd/system/runlevel6.target-> reboot.tar get

You can set different running levels for different needs:

For example, set the command line level (init 3) method:
[Root @ localhost ~] # Ln-svf/lib/systemd/system/runlevel3.target/etc/systemd/system/default.tar get
Or
[Root @ localhost ~] # Ln-svf/lib/systemd/system/multi-user.target/etc/systemd/system/default.tar get
Or
[Root @ localhost ~] # Systemctl set-default multi-user.target

How to set the window level (init 5:
[Root @ localhost ~] # Ln-svf/lib/systemd/system/runlevel5.target/etc/systemd/system/default.tar get
Or
[Root @ localhost ~] # Ln-svf/lib/systemd/system/graphical.tar get/etc/systemd/system/default.tar get
Or
[Root @ localhost ~] # Systemctl set-default graphical.tar get

----------------------------- Split line -----------------------------

Modify the system running level:
1. systemd uses a more free target substitution than sysvinit. The 3rd class is replaced by multi user.tar get. Use graphical.tar get to replace the 5th class. Runlevel3.targetand runlevel5.tar get are symbolic links to multi user.targetand graphical.tar get respectively.
You can use the following command to switch to "running level 3 ":
Systemctl isolate multi-user.target or systemctl isolate runlevel3.target

You can use the following command to switch to "running level 5 ":
Systemctl isolate graphical.tar get or systemctl isolate runlevel5.target
2. how to change the default running level?
Systemd uses links to point to the default running level. Before creating a new link, run the following command to delete the existing link: rm/etc/systemd/system/default.tar get
Default start Level 3:
Ln-sf/lib/systemd/system/multi-user.target/etc/systemd/system/default.tar get

Default startup running Level 5:
Ln-sf/lib/systemd/system/graphical.tar get/etc/systemd/system/default.tar get

Systemd does not use the/etc/inittab file.

----------------------------- Split line -----------------------------

How to view the current running level?
The old runlevel command can still be used in systemd. You can continue to use it, although systemd uses the 'target' concept (multiple 'targets' can be activated at the same time) to replace the runlevel of the previous system.
The equivalent systemd command is systemctl list-units-type = target.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.