如上個隨筆所言,Linux分爲7個啓動級別:網絡
如今不少Linux系統都默認啓動等級爲5。若是咱們想切換系統等級,可以使用init命令spa
init 3
這樣就能夠切換到多用戶狀態且帶有網絡文件系統了。這種方式對於CentOS7也適用。但想修改默認啓動級別,CentOS7同其餘Linux稍顯不一樣了。code
對於傳統的設置方法,只要修改/etc/inittab文件便可,將默認的啓動級別改成須要改動的級別。blog
打開CentOS7的/etc/inittab,發現該文件與其餘Linux不一樣:get
# 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
按照該文件所說的,runlevels被targets所取代,即CentOS7採用加載target的方式來替代以前的啓動級別。其中有兩個重要的target:multi-user.target與graphical.target。它們分別表示運行級別中的3與5級別。it
經過systemctl get-default可得到默認啓動的targetclass
經過systemctl set-default設置默認啓動的targetsed
那麼,想修改成多用戶狀態只需執行:方法
systemctl set-default multi-user.target
修改成圖形界面執行:tab
systemctl set-default graphical.target