Command Introduction: shutdown, poweroff, reboot, halt, and init can all be shut down. /Sbin/halt [-n] [-w] [-d] [-f] [-I] [-p] [-h]/sbin/reboot [-n] [-w] [-d] [-f] [-I]/sbin/poweroff [-n] [-w]
Command overview
Shutdown, poweroff, reboot, halt, and init can all be shut down for general usage.
/Sbin/halt [-n] [-w] [-d] [-f] [-I] [-p] [-h]
/Sbin/reboot [-n] [-w] [-d] [-f] [-I]
/Sbin/poweroff [-n] [-w] [-d] [-f] [-I] [-h]
[Root @ linux ~] $ Reboot -- h
Usage: reboot [-n] [-w] [-d] [-f] [-h] [-I]
-N: not synchronized before stopping the system
-W: write only the wtmp reboot record and exit.
-D: Do not write the wtmp record
-F: forced shutdown or restart
-H: keep the hard disk in standalone mode
-I: disable all network interfaces.
Shutdown process
1. refresh the hard disk cache:
2. record restart events: (/var/run/utmp,/var/log/wtmp)
3. kill all processes:
4. restart the machine:
Shutdown example
# Shutdown-h now # shutdown immediately
# Shutdown-h 02:30 'halt' # shut down at. pay attention to the local time.
# Halt-p # immediate shutdown
# Init 0 # immediately switch the system running level to 0, that is, shutdown
# Shutdown-r now # restart immediately
Restart example
# Shutdown-k now 'reboot' # send a warning message, but it does not actually shut down.
# Shutdown-t10-r now # restart immediately, but the delay between warning and delete processes is 10 seconds.
# Init 6 # immediately switch the system running level to 6, that is, restart
# Shutdown-r + 10 'reboot' # restart after 10 minutes
# Shutdown-c # cancel the previous shutdown command
# Shutdown now # switch to single-user mode (when no option is added)
Shutdown preparation
Linux is no better than Windows. if it cannot be shut down normally, it may cause file system damage because it is too late to write data back to a file. Therefore, pay attention to the following before shutdown:
1. observe the system status
- Use the who command to view online users
- Run the netstat-a command to check the online network status.
- Run the ps aux command to view the background execution program.
2. Notify Online users # shutdown-k now 'System will reboot in 30 minutes! '
3. use the correct command # First, determine whether to shut down or restart, and pay attention to parameters.
4. pay attention to data synchronization # use sync data synchronization to write data to disks
Other instructions
1. View restart records
# Last reboot
2. remotely start the machine
# Ssh root @ server/sbin/reboot
# Ssh root@192.168.0.1/sbin/shutdown-r now