1.centos6啟動流程
image.png
2.centos7啟動流程
image.png
3.centos6與centos7區(qū)別
image.png
4.運行級別
centos6
運行級別 | 作用 |
---|---|
0 | 關機 |
1 | 單用戶模式(超級權限 必須面對面實體硬件) |
2 | 暫未使用 |
3 | 字符界面(黑框) |
4 | 暫未使用 |
5 | 圖形界面 |
6 | 重啟 |
單用戶
臨時性的操作
[root@oldboy ~]# runlevel 查看級別
N 3 N 表示上一次是什么級別
3 當前系統(tǒng)正在運行的級別
[root@oldboy ~]# init 3 切換到3級別上
永久操作 /etc/inittab
centos7
system V init運行級別 | systemd目標名稱 | 作用 |
---|---|---|
0 | runlevel0.target,poweroff.target | 關機 |
1 | runlevel0.target,rescue.target | 單用戶模式 |
2 | runlevel0.target,multi-user.target | .... |
3 | runlevel0.target,multi-user.target | 多用戶文本界面 |
4 | runlevel0.target,multi-user.target | .... |
5 | runlevel0.target,graphical.target | 多用戶的圖形界面 |
6 | runlevel0.target,reboot.target | 重啟 |
multi-user.target: analogous to runlevel 3
graphical.target: analogous to runlevel 5
查看當前的運行級別
[root@oldboy ~]# systemctl get-default
multi-user.target
修改系統(tǒng)下次啟動時候的運行級別
[root@oldboy ~]# systemctl set-default multiuser.target
systemd
systemctl start nginx 開啟
systemctl stop nginx 停止
systemctl restart nginx 重新啟動
systemctl reload nginx 重新加載配置文件
systemclt status nginx 查看當前服務的狀態(tài)
systemctl enable nginx 下一次開機啟動nginx,于當前無關 systemctl disable
systemctl disable nginx 下一次開機不啟動nginx,于當前無關
當我們使用systemctl啟動一個守護進程后聋涨,可以通過systemctl status查看此守護進程的狀態(tài)
狀態(tài) | 描述 |
---|---|
loaded | 服務單元的配置文件已經被處理 |
active(runnning) | 服務持續(xù)運行 |
active(exited) | 服務成功完成一次的配置 |
active(waiting) | 服務已經運行但在等待某個事件 |
inactive | 服務沒有在運行 |
enabled | 服務設定為開機運行 |
disable | 服務設定為開機不運行 |
static | 服務開機不啟動,但可以被其他服務調用啟動 |
[root@oldboy ~]# #關機
shutdown -h now
poweroff halt
init 0
systemctl poweroff
[root@oldboy ~]# #重啟
reboot
shutdown -r now
init 6
systemctl reboot
單用戶模式 超級權限 必須面對實體硬件
能正常引導進入系統(tǒng)
- 配置文件錯誤導致無法啟動
-
忘記ROOT密碼 ( 快照 | 單用戶修改)
GRUB界面按"e"
image.png
之后就可以進入下面的界面。
image.png
進行修改
image.png
登錄到單用戶字符界面修改密碼,然后退出
image.png
https://mp.weixin.qq.com/s/1f-zCq8j4gL3xiB3AV9K3A 忘記root密碼
救援模式 系統(tǒng)無法正常進入 比如沒有內核 比如grub被修改比如系統(tǒng)崩潰
- 系統(tǒng)崩潰, 要保留重要的數(shù)據(jù)的時候
- grub菜單出現(xiàn)問題, linux windows