Centos 7 running-level switch

Source: Internet
Author: User

In versions earlier than centos 7, the system running level is defined through the/etc/inittab file:

[[email protected] ~]$ cat /etc/centos-release 
CentOS release 6.4 (Final) [[email protected] ~]$ cat /etc/inittab 
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are 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 are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
# 
id:3:initdefault: [[email protected] ~]$ 

In centos 7, the file is no longer used to define the system running level. The related running level settings are invalid:

[[email protected] etc]$ cat /etc/centos-release 
CentOS Linux release 7.0.1406 (Core) [[email protected] etc]$ cat /etc/inittab 
# inittab is no longer used when using systemd.
#
# ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# Ctrl-Alt-Delete is handled by /etc/systemd/system/ctrl-alt-del.target
#
# systemd uses ‘targets‘ instead of runlevels. By default, there are two main targets:
#
# multi-user.target: analogous to runlevel 3 # graphical.target: analogous to runlevel 5 #
# To set a default target, run:
#
# ln -sf /lib/systemd/system/<target name>.target /etc/systemd/system/default.target
#
id:3:initdefault: #invalid [[email protected] etc]$ 

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

[[email protected] system] $ls - LTR/lib/systemd/system/runlevel *
13 July 30 and LRWXRWXRWX. 1 root root/lib/systemd/system/runlevel1. The target - > rescue. The target
LRWXRWXRWX. 1 root root 15 July 30 and the/lib/systemd/system/runlevel0. The target - > poweroff. The target
17 July 30 and LRWXRWXRWX. 1 root root/lib/systemd/system/runlevel2. The target - > multi - user. Target
17 July 30 and LRWXRWXRWX. 1 root root/lib/systemd/system/runlevel3. The target - > multi - user. Target
17 July 30 and LRWXRWXRWX. 1 root root/lib/systemd/system/runlevel4. The target - > multi - user. Target
16 July 30 and LRWXRWXRWX. 1 root root/lib/systemd/system/runlevel5. The target - > graphical. The target
13 July 30 and LRWXRWXRWX. 1 root root/lib/systemd/system/runlevel6. The target - > reboot. Target 

You can set different running levels for different needs:
For example, set the command line level method:

Ln-SF/lib/systemd/system/runlevel3.target/etc/systemd/system/default.tar get
Or
Ln-SF/lib/systemd/system/multi-user.target/etc/systemd/system/default.tar get
Or
Systemctl set-default multi-user.target

How to set the window level:

Ln-SF/lib/systemd/system/runlevel5.target/etc/systemd/system/default.tar get or Ln-SF/lib/systemd/system/graphical.tar get/etc/systemd/system/ default.tar get
Or
Systemctl set-default graphical.tar get

 

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.