Linux系統的啟動原理
RHEL的啟動原理
BIOS自檢-MBR-啟動GRUB-加載內核-systemd的init進程
systemd的初始化進程
加載需要的服務,掛載文件系統/etc/fstab
systemd是linux內核啟動的第一個進程,取代了init
systemd 的優點:
啟動速度快,提供系統服務的快照,服務自動實時更新
pstree 命令可以查看第一個啟動的進程,pid是1
---------------
init 與systemd的比較
init0 systemctl poweroff 關機
init1 systemctl isolate rescue.target 單用戶模式
init3 systemctl isolate multi-user.target 多用戶模式,字符界面
init5 systemctl isolate.graphical.target 圖形化界面
init6 systemctl reboot 重啟系統
vim /etc/inittab 系統運行級別說明文件
查看當前默認的運行級別
systemctl get-default
設置默認的運行
systemctl set-default
調用字符界面
systemctl isolate multi-user.target
調用字符界面並設置為默認運行級別
systemctl set-default multi-user.target
切換運行級別
systemctl isolate multi-user.target
grub的引導設置
vim /etc/default/grub
使用grub2-mkconfig 讓修改生效
查看grub的配置文件
vim /boot/grub2/grub.cfg
覆蓋執行
grub2-mkconfig -o /boot/grub2/grub.cfg
systemd 的主要命令是systemctl
systemctl start 服務名稱 啟動一個服務
systemctl restart 服務名稱 重啟一個服務
systemctl stop 服務名稱 停止一個服務
systemctl status 服務名稱 查看一個服務的狀態
systemctl enable 服務名稱 設置一個服務開機自動啟動
systemctl disable 服務名稱 設置一個服務開機自動關閉
init5 切換到圖形化界面
-----------------------------
查看atd服務的狀態、
systemctl status atd
安裝Apache軟件包
yum -y install httpd
systemctl enable httpd
ststemctl disable httpd
------------------
查看系統中的服務那些是開機自啟動的
systemctl list-unit-files --type service
查看系統中服務占用資源的狀態
systemd-cgtop