欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

centos 7修改默认运行级别

程序员文章站 2022-07-03 23:19:50
...

查看当前的运行级别

编辑文件:

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

通过文件,可以了解到,centos7有两种运行级别:
3:multi-user.target
5:graphical.target
查看当前的运行级别:systemctl get-default 命令
设置默认的启动级别:systemctl set-default TARGET.target

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

graphical.target表示当前的运行级别是图形界面。

设置默认的运行级别为mulit-user

[[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 get-default
multi-user.target
[[email protected] ~]# 

通过systemctl get-default查看到当前的运行级别为:multi-user.target,该命令重启以后生效。

切换当前的运行级别

systemctl isolate multi-user.target
systemctl isolate graphical.target

在不重启的情况下,切换运行级别

相关标签: centos7 linux