CentOS 7 運行層級切換

來源:互聯網
上載者:User

標籤:

CentOS 7 之前的版本是通過 /etc/inittab 檔案來定義系統運行層級:

[[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] ~]$ 

CentOS 7 版本不再使用該檔案定義系統運行層級,相關運行層級設定無效:

[[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:  #無效[[email protected] etc]$ 

新版本的運行層級都定義在 /lib/systemd/system下:

[[email protected] system]$ ls -ltr /lib/systemd/system/runlevel*lrwxrwxrwx. 1 root root 13 7月  30 14:22 /lib/systemd/system/runlevel1.target -> rescue.targetlrwxrwxrwx. 1 root root 15 7月  30 14:22 /lib/systemd/system/runlevel0.target -> poweroff.targetlrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel2.target -> multi-user.targetlrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel3.target -> multi-user.targetlrwxrwxrwx. 1 root root 17 7月  30 14:22 /lib/systemd/system/runlevel4.target -> multi-user.targetlrwxrwxrwx. 1 root root 16 7月  30 14:22 /lib/systemd/system/runlevel5.target -> graphical.targetlrwxrwxrwx. 1 root root 13 7月  30 14:22 /lib/systemd/system/runlevel6.target -> reboot.target

可以針對不同需要設定不同的運行層級:
如設定命令列層級方法:

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

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

systemctl set-default multi-user.target

設定視窗層級方法:

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

systemctl set-default graphical.target

CentOS 7 運行層級切換

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.