1. 程式人生 > >Centos7更改默認啟動模式

Centos7更改默認啟動模式

centos啟動配置

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更改默認啟動模式