Correct shutdown method in Linux Table of Contents
- 1. Prepare for shutdown
- 1.1 observe the system Usage Status
- 1.2 notify online users of Shutdown Time
- 2 shutdown command
- 2.1 sync
- 2.2 Shutdown
- 2.3 reboot
- 2.4 halt
- 2.5 poweroff
- 3. execution level
- 3.1 Classification
- 3.2 Level Switch
1. Prepare 1.1 before shutdown to observe the system Usage Status
- Who is online: WHO
- Networking status: netstat-
- Programs executed in the background: PS-Aux
1.2 notify online users of Shutdown Time
- Shutdown + 2 "the machine will shutdown" # shut down after 2 minutes, and notify the online user
2 shutdown command 2.1 sync
- Write Data not written to hard disk in memory to Hard Disk
2.2 Shutdown
- Shutdown now # shut down immediately
- Shutdown + 2 # shutdown in 2 minutes
- Shutdown # shutdown
- Shutdown + 2 "the machine will shutdown" # shut down after 2 minutes, and notify the online user
2.3 reboot
- Restart. After parameters are added, halt and poweroff can be implemented.
2.4 halt points to the reboot link, which is equivalent to the shutdown-H 2.5 poweroff point to the reboot link, which is equivalent to the halt3 execution level of 3.1 levels
- Run level 0: Shutdown
- Run level 3: plain text mode
- Run level 5: graphic interface mode
- Run level 6: restart
3.2 Level Switch
- Init 0 # Switch to level 0, that is, shutdown
Appendix: differences between shutdown, halt, and poweroff
Shutdown: Shut down the system. Refer to the existing explanation: "The command safely shuts down the system. It is very dangerous for some users to disable Linux by directly disconnecting the power supply. Different from windows, Linux runs many processes in the background, therefore, force shutdown may lead to data loss in the process, making the system unstable, or even damaging hardware in some systems. When the shutdown command is used before the system is shut down, the system administrator notifies 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 shut down directly or wait for a certain period of time to restart. This is determined by the signal that all processes receive from the system [Signal. This allows programs like VI to have time to store the files being edited, while programs like mail and news can leave normally. "shutdown will run the script in/etc/rc0.d, that is to say, the runlevel 0 script will be executed. Halt does not. Poweroff: turning off the system power. poweroff is just the soft link of halt. The halt command is executed. The halt command can be understood as follows: 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.
Source: http://zhidao.baidu.com/question/477827584.html