CentOS 7 之前要设置开机默认不启动图形界面是通过 vim /etc/inittab 来将 id:3:initdefault:
但是,在 CentOS 7 之后就不是这样子了:
CentOS 7 由于使用 systemd 而不是 init,所以不能通过修改 inittab 文件来修改开机启动模式。
例如:我的CentOS版本是CentOS-7-x86_64-DVD-1804,现在我 vim /etc/inittab,结果:
[root@jianbao-pc ~]# vim /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 /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:相当于之前的更改运行级别为3,意思就是命令行;
- graphical.target:相当于之前的更改运行级别为5,意思就是图形界面(graphical中文意思是图形);
查看当前的开机默认运行方式:systemctl get-default
[root@jianbao-pc ~]# systemctl get-default multi-user.target
设置开机不启动图形界面:
systemctl set-default multi-user.target
设置开机启动图形界面:
systemctl set-default graphical.target