首頁 > 軟體

CentOS7修改預設執行級別

2020-06-16 17:43:15

在虛擬機器新安裝了個CentOS7,圖形介面啟動太慢,想調整一下按照以前的經驗改執行級別,輸入:

vi /etc/inittab

然後發現跟之前不一樣了,在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 /usr/lib/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 view current default target, run:
# systemctl get-default
#
# To set a default target, run:
# systemctl set-default TARGET.target
#

仔細讀一下上面的提示
multi-user.target 類似與之前的runlevel 3
graphical.target 類似與之前的runlevel 5

按照上面的提示,檢視當前的預設target輸入命令:


[root@localhost ~]# systemctl get-default
graphical.target
[root@localhost ~]#
當前為graphical.target

修改為命令模式multi-user.target:

[root@localhost ~]# systemctl set-default multi-user.target
rm '/etc/systemd/system/default.target'
ln -s '/usr/lib/systemd/system/multi-user.target' '/etc/systemd/system/default.target'
[root@localhost ~]#

檢視一下當前,發現得到預期要求:

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

最後重新啟動發現,果然是命令模式~~

本文永久更新連結地址http://www.linuxidc.com/Linux/2016-04/130558.htm


IT145.com E-mail:sddin#qq.com