Centos7更改默认启动模式
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7更改默认启动模式相关的知识,希望对你有一定的参考价值。
1.目的
因为图形界面比较占用资源,在部署中为了不浪费资源,我们一般使用命令行界面,有需要的时候使用命令startx切换到图形界面
2.查看/etc/inittab文件,cat /etc/inittab
[[email protected] ~]# 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
#
3.查看当前默认模式
使用命令:systemctl get-default查看
[[email protected] ~]# systemctl get-default
multi-user.target
[[email protected] ~]#
4.设置默认模式
使用命令:systemctl set-default TARGET.target设置默认模式
systemctl set-default multi-user.target
systemctl set-default graphical.target
[[email protected] ~]# 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.
[[email protected] ~]# systemctl set-default graphical.target
Removed symlink /etc/systemd/system/default.target.
Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.
5.重启验证
命令行模式切换到图形界面运行命令:startx
图形界面切换到命令行界面使用:CTRL+ALT+F3
命令行界面切换到图形界面使用:CTRL+ALT+F5
以上是关于Centos7更改默认启动模式的主要内容,如果未能解决你的问题,请参考以下文章