1. 程式人生 > >[Linux] 關機和重啟命令詳解

[Linux] 關機和重啟命令詳解

Linux有如下的關機和重啟命令:shutdown, reboot, halt, poweroff,那麼它們有什麼區別呢?

shutdown - 建議使用的命令

shutdown是最常用也是最安全的關機和重啟命令,它會在關機之前呼叫fsck檢查磁碟,其中-h和-r是最常用的引數: [plain] view plaincopyprint?在CODE上檢視程式碼片派生到我的程式碼片
  1. -h:停止系統服務並關機  
  2. -r: 停止系統服務後重啟  
-h:停止系統服務並關機
-r: 停止系統服務後重啟
下面看幾個例子: [plain] view plaincopyprint?在CODE上檢視程式碼片派生到我的程式碼片
  1. shutdown -h now  --立即關機  
  2. shutdown -h 10:53  --到10:53關機,如果該時間小於當前時間,則到隔天  
  3. shutdown -h +10  --10分鐘後自動關機  
  4. shutdown -r now  --立即重啟  
  5. shutdown -r +30 'The System Will Reboot in 30 Mins'   --30分鐘後重啟並併發送通知給其它線上使用者  
shutdown -h now  --立即關機
shutdown -h 10:53  --到10:53關機,如果該時間小於當前時間,則到隔天
shutdown -h +10  --10分鐘後自動關機
shutdown -r now  --立即重啟
shutdown -r +30 'The System Will Reboot in 30 Mins'   --30分鐘後重啟並併發送通知給其它線上使用者

reboot 

reboot表示立即重啟,效果等同於shutdown -r now

poweroff

poweroff表示立即關機,效果等同於shutdown -h now,在多使用者模式下(Run Level 3)不建議使用。

halt

不理會目前系統狀況下,進行硬體關機,一般不建議使用 文章來源:http://blog.csdn.net/dbanote/article/details/17411107