CentOS 7 RunLevel Switch

Source: Internet
Author: User

Versions prior to CentOS 7 are defined by the/etc/inittab file to define the system RunLevel:

[Email protected] ~]$ cat/etc/centos-Release CentOS release6.4 (Final) [[email protected]~]$ cat/etc/Inittab#Inittab is a used by upstart for the default runlevel.##ADDING other CONFIGURATION, here would have the NO EFFECT on YOUR SYSTEM.##System initialization is started by/etc/init/rcs.conf##individual runlevels is started by/etc/init/rc.conf##Ctrl-alt-delete is handled by/etc/init/control-alt-delete.conf##Terminal Gettys is handled by/etc/init/tty.conf and/etc/init/serial.conf,#With configuration in/etc/sysconfig/init.##for information on how to write upstart event handlers, or how#upstart works, see Init (5), init (8), and Initctl (8).##Default RunLevel. The runlevels used is:#0-halt (do not set Initdefault to this)#1-single User Mode#2-multiuser, without NFS (the same as 3, if you don't have networking)#3-full Multiuser Mode#4-unused#5-x11#6-reboot (do not set Initdefault to this)#Id:3:initdefault:[[Email protected]~]$

The CentOS 7 version no longer uses this file to define the system RunLevel, and the associated run-level settings are invalid:

[Email protected] etc]$ cat/etc/centos-release CentOS Linux release7.0.1406(Core) [[email protected]-11r2-rac1 etc]$ cat/etc/Inittab # Inittab isNo longer used whenusingsystemd.## ADDING CONFIGURATION here would have NO EFFECT on YOUR system.## Ctrl-alt-delete isHandled by/etc/systemd/system/ctrl-alt-del.target## Systemd uses'Targets'Instead of Runlevels. Bydefault, there is the main targets:## multi-user.target:analogous to RunLevel3# graphical.target:analogous to RunLevel5# # toSetAdefaultTarget, run:## ln-sf/lib/systemd/system/<target name>.target/etc/systemd/system/default. Target#id:3: Initdefault: #无效 [[email protected]-11r2-rac1 etc]$

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

[Email protected] system]$ ls-ltr/lib/systemd/system/runlevel*lrwxrwxrwx.1Root root -July -  -: A/lib/systemd/system/runlevel1.targetrescue.targetlrwxrwxrwx.1Root root theJuly -  -: A/lib/systemd/system/runlevel0.targetpoweroff.targetlrwxrwxrwx.1Root root -July -  -: A/lib/systemd/system/runlevel2.target-multi-user.targetlrwxrwxrwx.1Root root -July -  -: A/lib/systemd/system/runlevel3.target-multi-user.targetlrwxrwxrwx.1Root root -July -  -: A/lib/systemd/system/runlevel4.target-multi-user.targetlrwxrwxrwx.1Root root -July -  -: A/lib/systemd/system/runlevel5.targetgraphical.targetlrwxrwxrwx.1Root root -July -  -: A/lib/systemd/system/runlevel6.target-Reboot.target

You can set different runlevel for different needs:

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

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

To set the window level (init 5) Method:

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

-----------------------------Split Line-----------------------------

To modify the system operating level:
1. SYSTEMD uses a more free target replacement than the Sysvinit run level. The 3rd run level is replaced with Multi-user.target. The 5th run level is replaced with Graphical.target. Runlevel3.target and Runlevel5.target are symbolic links that point 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

You can use the following command to switch to run Level 5:
Systemctl isolate Graphical.target or Systemctl isolate Runlevel5.target
2. How do I change the default runlevel?
SYSTEMD uses links to point to the default runlevel. Before creating a new link, you can delete the existing link by following the command: Rm/etc/systemd/system/default.target
Default startup Run Level 3:
Ln-sf/lib/systemd/system/multi-user.target/etc/systemd/system/default.target

Default startup Run Level 5:
Ln-sf/lib/systemd/system/graphical.target/etc/systemd/system/default.target

SYSTEMD does not use/etc/inittab files.

-----------------------------Split Line-----------------------------

How do I see the current runlevel?
The old RunLevel command can still be used under SYSTEMD. You can continue to use it, although SYSTEMD replaces the previous system's runlevel with the ' target ' concept (multiple ' target ' can be activated simultaneously).
The equivalent SYSTEMD command is Systemctl list-units–type=target

CentOS 7 RunLevel Switch

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.