码迷,mamicode.com
首页 > 系统相关 > 详细

Linux运行级别

时间:2019-02-14 23:54:22      阅读:374      评论:0      收藏:0      [点我收藏+]

标签:center   详解   shu   通过   config   span   net   header   文件   

Linux运行级别

运行级别介绍

运行级别就是操作系统当前正在运行的功能级别,级别是从0到6。Centos7系统之前的版本是通过/etc/inittab文件来定义系统,而CentOS7用的是/lib/systemd/system/runlevel*

实际操作

[root@db01 ~]# cat /etc/redhat-release
CentOS release 6.7 (Final)

[root@db01 ~]# 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)  # 运行级别0:系统停机状态,系统默认运行级别不能设为0,否则不能正常启动
# 1 - Single user mode  # 运行级别1:单用户工作状态,root权限,用于系统维护,禁止远程登陆
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking) #运行级别2:多用户状态(没有NFS)
# 3 - Full multiuser mode  #运行级别3:完全的多用户状态(有NFS),登陆后进入控制台命令行模式
# 4 - unused  #运行级别4:系统未使用,保留
# 5 - X11 #运行级别5:X11控制台,登陆后进入图形GUI模式
# 6 - reboot (Do NOT set initdefault to this) #运行级别6:系统正常关闭并重启,默认运行级别不能设为6,否则不能正常启动
#

id:3:initdefault:    # 表示运行级别3,是默认的

CentOS 7 版本不再/etc/inittab使用该文件定义系统运行级别,相关运行级别设置无效;新版本的运行级别都定义在/lib/systemd/system/runlevel*

[root@db01 ~]# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core)

[root@db01 ~]# ll /lib/systemd/system/runlevel*
lrwxrwxrwx. 1 root root 15 Dec 3 2017 /lib/systemd/system/runlevel0.target -> poweroff.target
lrwxrwxrwx. 1 root root 13 Dec 3 2017 /lib/systemd/system/runlevel1.target -> rescue.target
lrwxrwxrwx. 1 root root 17 Dec 3 2017 /lib/systemd/system/runlevel2.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Dec 3 2017 /lib/systemd/system/runlevel3.target -> multi-user.target
lrwxrwxrwx. 1 root root 17 Dec 3 2017 /lib/systemd/system/runlevel4.target -> multi-user.target
lrwxrwxrwx. 1 root root 16 Dec 3 2017 /lib/systemd/system/runlevel5.target -> graphical.target
lrwxrwxrwx. 1 root root 13 Dec 3 2017 /lib/systemd/system/runlevel6.target -> reboot.target

7版本和之前版本对应

init级别systemctl target
0 shutdown.target
1 emergency.target
2 rescure.target
3 multi-user.target
4
5 graphical.target
6

设置运行级别

命令格式:
systemctl [command] [unit.target]
参数详解:
- get-default:获取当前的target
- set-default:设置指定的target为默认的运行级别
- isolate:切换到指定的运行级别

[root@localhost ~]# systemctl get-default #获取当前运行级别
[root@localhost ~]# systemctl set-default multi-user.target #设置默认运行级别为multi-user
[root@localhost ~]# systemctl isolate multi-user.target #在不重启情况下,切换到multi-user
[root@localhost ~]# systemctl isolate graphical.target #在不重启的情况下,切换到图形界面

Linux运行级别

标签:center   详解   shu   通过   config   span   net   header   文件   

原文地址:https://www.cnblogs.com/LEO00/p/10381246.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!