In Linux, some common shutdown and restart Commands include shutdown, halt, reboot, and init, which can be used to restart the system. However, the internal working process of each command is different, through the introduction in this article, we hope you can use various shutdown commands more flexibly.
1. Shutdown
The shutdown command safely shut down the system. before the system is shut down, the system administrator will notify all logged-on users that the system will be shut down. The LOGIN command is frozen, meaning that new users cannot log on again. It is possible to directly shut down or wait for a certain period of time to shut down, or restart. This is determined by the signal that all processes receive from the system [Signal. This allows users like VIProgramYou have time to store documents that are currently being edited, and programs such as mail and news can exit normally.
Shutdown is to send a signal to the INIT program and ask it to change the runlevel. Runlevel 0 is used to stop [halt] And runlevel 6 is used to reactivate the [reboot] system.
Common command set for shutdown:
# Shutdown-H now
The preceding command is equivalent to halt.
# Shutdown + 5 "system will shutdown after 5 minutes"
Shut down in 5 minutes and send a warning message to the Login User
# Shutdown-R
System restart
2. Halt-the simplest shutdown command
In fact, halt calls shutdown-H. When halt is executed, the application process is killed and the sync system call is executed. After the file system write operation is completed, the kernel is stopped.
# Halt
3. Reboot
The reboot process is similar to that of halt, but it causes host restart, while halt is shutdown.
# Reboot
4. init
Init is the ancestor of all processes, and its Process number is always 1. Therefore, sending a term signal to init will terminate all user processes and daemon processes. Shutdown uses this mechanism. Init defines eight runlevels. init 0 indicates shutdown, and init 1 indicates restart.
# Init 0
Shut down.
# Init 1
Restart.