Linux 之 init 命令详解
文章
林里克斯
试验平台:
CentOS Linux release 7.6.1810
1.init 命令详解
$ init --help
--help #打印帮助信息
--no-wall #在停止/关闭/重启之前不要发送 wall 消息
0 #关闭机器电源
6 #重新启动机器
2, 3, 4, 5 #切换到对应的 runlevelX
1, s, S #进入救援模式
q, Q #重新加载 init 守护进程配置
u, U #重新执行init守护进程
2.每个数字的含义
| 每个数字的含义 {0-6} | |
|---|---|
| 数值 | 含义 |
| 0 | halt 关机(不要将默认级别设置为此值) |
| 1 | single user mode 单用户模式/救援模式 |
| 2 | multiuser 无网络连接和 NFS 的多用户命令行模式 |
| 3 | full multiuser mode 有网络连接的多用户命令行模式 |
| 4 | unused 目前未定义 |
| 5 | x11 图形界面的多用户模式,X11(XWindowns) |
| 6 | reboot 重启(不要将默认级别设置为此值) |
3.查看当前运行的级别
$ runlevel
N 3
4.CentOS 7 之前设置默认启动级别
$ 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:5:initdefault:
5.CentOS 7 设置启动级别
注意:
CentOS 7下配置/etc/inittab已不再支持,配置了也不会生效。用以下配置:
multi-user.target: 运行级别 3
graphical.target: 运行级别 5
$ systemctl get-default
graphical.target
#查看当前运行的级别,与 runlevel 一样,但是显示内容不一致
$ systemctl set-default multi-user.target
#设置为运行级别 3
Over~
版权协议须知!
本篇文章来源于 Uambiguous ,如本文章侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意
1834 0 2020-12-04
博主卡片
运维时间
搭建这个平台,只为分享及记载自己所遇之事和难题。
现在时间 2025-12-05
今日天气
随机推荐
12-12
MySQL 之双主搭建
02-05
Linux 之打包备份命令 tar 详解
09-01
Zabbix 监控 Nginx 的连接状态
03-24
Linux 之日志处理系统 rsyslog
站点统计
- 文章总数:241篇
- 分类总数:29个
- 评论总数:15条
- 本站总访问量 487992 次
@ymidsuwfoa 这篇文章不错!
@svmuvwpuqi 真棒!
@smdxydrauu 博主太厉害了!
@xiaozi 最后的分享的镜像下载地址打不开 服务器没有开机吗?
@yuanyuan 为什么我的4b安装centos7.9 插上tf卡 显示不兼...
@Wong arrhenius 牛比
@MakerFace 厉害了!
@TongSir 老哥 更新下我的友链链接 https://blog.ton...


