1育瓜、簡述linux操作系統(tǒng)啟動流程
- 加載BIOS的硬件信息撞叽,獲取第一個啟動設(shè)備
- 讀取第一個啟動設(shè)備MBR的引導(dǎo)加載程序(grub)的啟動信息
- 加載核心操作系統(tǒng)的核心信息嗅辣,核心開始解壓縮撑蚌,并嘗試驅(qū)動所有的硬件設(shè)備
- 核心執(zhí)行init程序,并獲取默認的運行信息
- init程序執(zhí)行/etc/rc.d/rc.sysinit文件刽肠,重新掛載根文件系統(tǒng)
- 啟動核心的外掛模塊
- init執(zhí)行運行的各個批處理文件(scripts)
- init執(zhí)行/etc/rc.d/rc.local
- 執(zhí)行/bin/login程序溃肪,等待用戶登錄
- 登錄之后開始以Shell控制主機
2、制作一個只運行shell的linux系統(tǒng)
3音五、總結(jié)systemctl管理命令及system unit文件格式
systemctl管理命令
啟動:systemctl start name.service
停止:systemctl stop name.service
重啟:systemctl restart name.service
查看狀態(tài):systemctl status name.service
禁止自動和手動啟動:systemctl mask name.service
取消禁止 systemctl unmask name.service
查看某服務(wù)當(dāng)前激活與否的狀態(tài):systemctl is-active name.service
查看所有已經(jīng)激活的服務(wù):systemctl list-units --type|-t service
查看所有服務(wù):systemctl list-units --type service --all|-a
設(shè)定某服務(wù)開機自啟惫撰,systemctl enable name.service
設(shè)定某服務(wù)開機禁止啟動:systemctl disable name.service
查看所有服務(wù)的開機自啟狀態(tài) :systemctl list-unit-files --type service
查看服務(wù)是否開機自啟:systemctl is-enabled name.service
列出失敗的服務(wù):systemctl --failed --type=service
開機并立即啟動或停止 :systemctl enable --now postfix ,systemctl disable --now postfix
查看服務(wù)的依賴關(guān)系: systemctl list-dependencies name.service
殺掉進程:systemctl kill unitname
unit文件格式
- service unit: 文件擴展名為.service, 用于定義系統(tǒng)服務(wù)
- Socket unit: .socket, 定義進程間通信用的socket文件躺涝,也可在系統(tǒng)啟動時厨钻,延遲啟動服務(wù),實現(xiàn)按需啟動
- Target unit: 文件擴展名為.target坚嗜,用于模擬實現(xiàn)運行級別
- Device unit: .device, 用于定義內(nèi)核識別的設(shè)備
- Mount unit: .mount, 定義文件系統(tǒng)掛載點
- Snapshot unit: .snapshot, 管理系統(tǒng)快照
- Swap unit: .swap, 用于標(biāo)識swap設(shè)備
- Automount unit: .automount夯膀,文件系統(tǒng)的自動掛載點
- Path unit: .path,用于定義文件系統(tǒng)中的一個文件或目錄使用,常用于當(dāng)文件系統(tǒng)變化時惶傻,延遲激活服務(wù)棍郎,如:sp
4、破解centos7 密碼
- 重啟 blue 系統(tǒng)银室,按 e 鍵打斷啟動過程
- 修改 linux 行(ro 改 rw涂佃,末尾添加 rd.break)然后按 ctrl+x 啟動
- switch_root:/# chroot /sysroot/ //切換到根系統(tǒng)
- sh-4.2# echo redhat | passwd --stdin root //修改 root 口令為指定的字串
- sh-4.2# touch /.autorelabel //標(biāo)記下一次啟動重做 SELinux 標(biāo)記
- sh-4.2# exit //退出恢復(fù)模式
- switch_root:/# reboot //重啟系統(tǒng)