系统服务
1.开机启动流程
1.centos6启动流程
centos6
https://www.runoob.com/linux/linux-system-boot.html
2.centos启动流程
centos7
3.centos6和centos7区别?
区别
运行级别
centos6
0 | 关机 |
---|---|
1 | 单用户模式(超级权限 必须面对实体硬件) |
2 | 暂未使用 |
3 | 字符界面(黑框) |
4 | 暂未使用 |
5 | 图形界面 |
6 | 重启 |
centos6
#临时操作
[root@oldboy ~]# runlevel
N 3
#N 表示上一次是什么级别
# 3 当前系统正在运行的级别
[root@oldboy ~]# init 3
#切换到3级别上
[root@oldboy ~]# vim /etc/inittab
#永久操作
centos7
0 | 关机 |
---|---|
1 | 单用户模式(超级权限 必须面对实体硬件) |
2 | 暂未使用 |
3 | 字符界面(黑框) |
4 | 暂未使用 |
5 | 图形界面 |
6 | 重启 |
1.什么是运行级别,运行级别就是操作系统当前正在运行的功能级别
# multi-user.target: analogous to runlevel 3
# graphical.target: analogous to runlevel 5
#查看当前的运行级别
[root@oldboy ~]# systemctl get-default
multi-user.target
#修改系统下次启动时候的运行级别
[root@oldboy ~]# systemctl set-default multi-user.target
2.systemd
systemctl start nginx ##开启nginx
systemctl stop nginx ##停止运行nginx
systemctl restart nginx ##重新加载nginx
systemcatl status nginx ##查看nginx详细信息
systemctl enable nginx ##下一次开机启动nginx,与当前无关
systemctl disable nginx ##下一次开机nginx,于当前无关
当我们使用systemctl启动一个守护进程后,可以通过systemctl status查看此守护进程的状态
状态 | 描述 |
---|---|
loaded | 服务单元的配置文件已经被处理 |
active(running) | 服务持续运行 |
active(exited) | 服务成功完成一次配置 |
active(waiting) | 服务没有在运行 |
inactive | 服务没有在运行 |
enabled | 服务设定为开机运行 |
disabled | 服务设定为开机不运行 |
static | 服务开机不启动,但可以被其他服务调用启动 |
[root@oldboy ~]# #关机
shutdown -h now
poweroff
halt
init 0
systemctl reboot
[root@oldboy ~]# #重启
reboot
shutdown -r now
init 6
systemctl reboot
4单用户模式
前提条件:
能正常引导进入系统
有两种情况:
-配置文件错误导致无法启动
-忘机ROOT密码(快照|单用户修改)
密码丢失找回方法
重启centos系统,然后按照提示按“e”进入编辑模式
如果不确定系统是否开启了seLinux,找到linux16开头的行,将光标移动到改行的结尾然后输入 enforcing=0 init=/bin/bash
image.png
配置完成后根据提示按ctrl+x启动linux如下图配置
配置完成后,执行 exec /sbin/init命令重启系统
重启系统
重启系统后检验修改后的密码是否能登录,出现下图,表示密码修改并登录成功
image.png
**更详细内容请看
https://mp.weixin.qq.com/s/1f-zCq8j4gL3xiB3AV9K3A **
救援模式 系统无法正常进入 比如没有内核 比如grub被修改 比如系统崩溃
没有内核文件,只能使用 救援模式进入
系统崩溃,要保留重要数据的时候
grub 菜单出现问题