安装GNOME桌面后想设置默认启动桌面环境,结果发现centos 7的/etc/inittab文件和centos 6不一样了,特记录centos 7设置开机启动级别方法。

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 /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

通过该文件可以看出centos 7 用targets代替了启动级别的设置
multi-user.target类似于 级别3
graphical.target类似于 级别5

获取当前运行级别

systemctl get-default

设置运行级别为3

systemctl set-default multi-user.target

设置运行级别为5

systemctl set-default graphical.target