[root@localhost ~]# systemctl get-default graphical.target [root@localhost ~]# systemctl set-default multi-user.target Removed symlink /etc/systemd/system/default.target. Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target. [root@localhost ~]# systemctl get-default multi-user.target
使用systemctl get-default可以獲得當前的默認target;
使用systemctl set-default可以設置默認target,target可以是graphical.target、multi-user.target。
//graphical.target表示開機將默認進入圖形界面
//multi-user.target表示開機將默認進入文本界面
rm -f /etc/systemd/system/default.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
----------------------------------------------------------------------------------------------------------------------------------
網上各種策略將編輯 inittab文件,從 5--》3即可,centos 7 之后 用系統
graphical.target
"/etc/inittab" 17L, 511C 17,1 全部 # 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
重啟系統,就進入命令行模式了。