linux 运行级别
linux 运行级别
相关目录
CentOS8 相关目录由/etc/inittab变成 /etc/systemd/system/default.target
[ranan@hadoop102 ~]$ cat /etc/systemd/system/default.target
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
[Unit]
Description=Graphical Interface
Documentation=man:systemd.special(7)
Requires=multi-user.target
Wants=display-manager.service
Conflicts=rescue.service rescue.target
After=multi-user.target rescue.service rescue.target display-manager.service
AllowIsolate=yes
查看、设置默认运行级别
0 poweroff.target :关机,系统默认运行级别不能设为0,否则不能正常启动
1 rescue.target : 单用户 找回丢失密码有用,root权限,用于系统维护,禁止远程登录
2:多用户无网络
3 multi-user.target:多用户有网络服务,登陆后进入控制台命令行模式
4:保留
5 graphical.target:图形化界面
6 reboot.target:系统正常关闭重启,默认运行级别不能设为6,否则不能正常启动
查看默认运行级别
方式1:systemctl get-default
[ranan@hadoop102 ~]$ systemctl get-default
graphical.target
方式2:runlevel
[ranan@hadoop102 ~]$ runlevel
N 5
设置默认运行级别命令
设置默认命令行启动
[ranan@hadoop102 ~]# systemctl set-default multi-user.target
设置图形界面启动
[ranan@hadoop102 ~]# systemctl set-default graphical.target
切换当前运行级别
方法1:systemctl
//从命令行模式切换到图型模式
[ranan@hadoop102 ~]# systemctl isolate graphical.target
//切换到多用户的命令行模式
[ranan@hadoop102 ~]# systemctl isolate multi-user.target
方法2:init
init 0|1|3|5|6
常见问题
1.如果不小心将默认的运行级设置成0或7,怎么处理?
进入单用户模式,修改成正常。