在Redhat/Centos6中是通过runlevel来表达当前的启动模式的,比如3进入命令行,5进入桌面, 或者在桌面模式下,启动终端,用命令init 3切换到命令行模式下.

在Centos7下用下面的命令获取当前启动模式:

[root@centos211 ~]# systemctl get-default
graphical.target

查看/etc/inittab

[root@centos211 ~]# 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
#

通过提示,可以修改默认的启动模式为命令行:

[root@centos211 ~]# 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.

切换为图形模式使用:

systemctl set-default graphical.target