Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux 運行級別詳細說明:0-6 含義與切換指令

編輯:Linux 教學

Linux 透過 **Runlevel (運行級別)** 定義系統啟動後的服務狀態。理解各級別用途,能精準控制系統進入維護、文字、圖形或關機狀態。

七大標準運行級別

級別名稱描述典型用途
0Halt關機,系統完全停止關機指令 init 0、shutdown -h
1Single User單用戶維護模式,掛載根分區,無網路重設 root 密碼、檔案系統修復、備份
2Multi-user (No NFS)多用戶文字模式,不啟動 NFS 服務少見,特定無網路環境
3Full Multi-user完整多用戶文字模式(含網路、NFS)**伺服器標準運行級別**
4Unused保留,用戶自定義可自訂特殊服務組合
5Graphical多用戶圖形模式 (X11/Wayland)桌面版 Linux 預設
6Reboot重新啟動init 6、shutdown -r

查看與切換當前級別

runlevel          # 輸出如 "N 3" (前一級別 當前級別)
who -r            # 同樣顯示
init 3            # 切換至級別 3 (需 root)
telinit 5         # 同 init,systemd 系統建議用 systemctl

systemd 現代目標對照

Runlevelsystemd Target指令
0poweroff.targetsystemctl poweroff
1rescue.targetsystemctl rescue
2multi-user.targetsystemctl isolate multi-user.target
3multi-user.targetsystemctl isolate multi-user.target
4自定義-
5graphical.targetsystemctl isolate graphical.target
6reboot.targetsystemctl reboot

設定預設運行級別

  • SysVinit:編輯 /etc/inittab,修改 id:3:initdefault:。
  • systemd:systemctl set-default multi-user.target(文字模式)或 graphical.target。

重要提醒

  • **不要將預設級別設為 0 或 6**,否則系統無法正常啟動(無限關機/重啟循環)。
  • 單用戶模式 (1) 下根分區為讀寫,其他分區需手動掛載。
  • 緊急模式 (systemctl emergency) 比單用戶更精簡,連 /etc/fstab 也不掛載。
Copyright © Windows教程網 All Rights Reserved