5種Linux終端關機重啟命令

最近更新時間 2020-01-14 12:53:40

查詢Linux系統手冊頁可知,需要使用安全、優雅的命令來關閉運行中的系統。

在 Ubuntu 和 CentOS/RHEL 系統中,shutdown 是最常用的系統關機重啟命令。當使用 shutdown 命令後,系統會通知所有登錄用戶和進程,系統即將關閉。

下面將介紹這幾種不同的關機命令:

1. Shutdown 命令。

立即關閉系統。

shutdown -h now

10分鐘後關閉系統。

shutdown -h +10

 明天 00:45 關閉系統。

shutdown -h 00:45

取消關閉系統。

shutdown -c

2. Poweroff 命令

另一個可以用來關閉系統的命令是 poweroff ,效果等同於 shutdown -h now,在多用戶模式下(Run Level 3)不建議使用。

poweroff

3. Halt 命令

halt命令也可以關閉系統。不理會目前系統狀況下,進行硬件關機,一般不建議使用。

halt

4. Init 命令

init命令用於改變系統運行級別,系統總共有 0-6 級,第 0 級用於停止系統,一般不建議使用。

init 0

5. Systemctl 命令

最新的操作系統提供 systemctl 工具,替換以前的系統關機命令,來執行系統關機任務

關閉系統,同時通知所有用戶
systemctl poweroff
關閉系統,但是不斷電,同時通知所有用戶
systemctl halt
關閉系統,不通知用戶
systemctl --no-wall poweroff
顯示所有關閉詳情
journalctl -u systemd-shutdownd
rss_feed