Linux switch command (shutdown,reboot,halt,init)

Source: Internet
Author: User

Introduction to Commands

Shutdown,poweroff,reboot,halt,init can be shut down for general use.

/sbin/halt [-N] [-W] [-d] [-f] [-i] [-p] [-h]
/sbin/reboot [-N] [-W] [-d] [-f] [-I.]
/sbin/poweroff [-N] [-W] [-d] [-f] [-i] [-h]

[email protected] ~]$ reboot--h
Usage:reboot [-N] [-W] [-d] [-f] [-h] [-I.]
-N: not synchronized before stopping the system
-W: Write only wtmp reboot record and leave
-D: Do not write Wtmp records
-F: Forced shutdown or restart
-H: Leave the hard drive in stand-alone mode
-I: Turn off all network interfaces


Shutdown process

1. Flush the hard disk cache:
2. Log restart Event: (/var/run/utmp,/var/log/wtmp)
3. Kill All Processes:
4. Finally restart the machine:


Example of shutting down the machine

# shutdown-h Now #立刻关机
# shutdown-h ' Halt ' #2点30分关机, pay attention to the time of the machine
# halt-p #立刻关机
# init 0 #立即将系统运行级别切换为0, i.e. shutdown
# Shutdown-r Now #立刻重启


Restart Example

# shutdown-k Now ' reboot ' #发出警告讯息, but without really shutting down the machine.
# shutdown-t10-r now #立刻重启, but between warning and deleting processes, the delay is 10 seconds.
# init 6 #立即将系统运行级别切换为6, restart
# shutdown-r +10 ' reboot ' #10分钟后重启
# shutdown-c #取消之前的shutdown命令
# Shutdown now #切换至单人操作模式 (when no option is added)


Shutdown preparation

Linux is no more than Windows, and if it does not shut down properly, it may cause file system corruption because it is too late to write data back to the file. So before shutting down, pay attention to:

1. Observing the System status

    • View online users with the WHO command
    • View Network online status with the Netstat-a command
    • Use PS aux command to view background execution program

2. Notify online users #shutdown-k now ' System would reboot in minutes! '

3. Use the correct command #首先要搞清楚是关机还是重启, and then note the parameters

4. Note The data synchronization #使用sync数据同步写入磁盘


Other Notes

1. View Restart record

# last Reboot


2. Remote Boot machine

# ssh [email  Protected]/sbin/reboot
# SSH [email protected]/sbin/shutdown-r now

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.