CentOS7的运行级别

来源:互联网 发布:mac改变用户名 编辑:程序博客网 时间:2024/06/06 18:24
一 查看当前运行的级别
[root@localhost ~]# runlevel
N 5

二 运行级别概念
第三运行级:
multi-user.target
第五运行级:
graphical.target

前者是符号链接指向了后面的target
runlevel3.target -> multi-user.target
runlevel5.target -> graphical.target

三 运行级别的切换
切换到:运行级3
下面这方法可以
systemctl isolate multi-user.target
举例
[root@localhost ~]# systemctl isolate multi-user.target
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
[root@localhost ~]# runlevel
5 3

切换到:运行级5
下面方法可以
systemctl isolate graphical.target
[root@localhost ~]# systemctl isolate graphical.target
PolicyKit daemon disconnected from the bus.
We are no longer a registered authentication agent.
PolicyKit daemon reconnected to bus.
Attempting to re-register as an authentication agent.
We are now a registered authentication agent.
[root@localhost ~]# runlevel
3 5

四 修改开机默认运行级别
切换到运行级3
systemctl set-default multi-user.target
[root@localhost ~]# 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.

切换到运行级5
systemctl set-default graphical.target
[root@localhost ~]# 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.