Linux--系统运行级别

CentOS-6

级别 说明
0 关机
1 单用户模式(适用于root密码忘记,没有网络)
2 多用户模式,但是没有NFS
3 多用户模式,命令模式
4 没有使用
5 图形界面模式
6 重启

查看运行级别:

[root@localhost ~]# runlevel 
N 3

修改运行级别:

  • 临时切换:init 等级
  • 永久切换:修改/etc/inittab文件
    inittab文件内容:
[root@localhost ~]# cat /etc/inittab 
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)
# 
id:3:initdefault:

CentOS-7

inittab文件内容:

[root@localhost ~]# 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命令
# systemctl get-default
#
# To set a default target, run:                            #设置运行级别可以使用:systemctl set-default TARGET.target命令
# systemctl set-default TARGET.target
#

查看所有运行级别的target:

[root@localhost ~]# ls -l /usr/lib/systemd/system/runlevel*target
lrwxrwxrwx. 1 root root 15 Oct 21 16:47 /usr/lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Oct 21 16:47 /usr/lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Oct 21 16:47 /usr/lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Oct 21 16:47 /usr/lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Oct 21 16:47 /usr/lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Oct 21 16:47 /usr/lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Oct 21 16:47 /usr/lib/systemd/system/runlevel6.target -> reboot.target
posted @ 2019-11-21 20:53  忘川的彼岸  阅读(142)  评论(0编辑  收藏  举报