1. prepare 1.1 before shutdown to observe the system usage status & middot; who is online: who is going to be online? & middot; networking status: netstat-a & middot; & nbs
1. Prepare for shutdown
1.1 observe the system usage status
· Who is online: who
· Networking status: netstat-
· Background programs: ps-aux
1.2 notify online users of shutdown time
· Shutdown + 2 "The machine will shutdown" # shut down after 2 minutes, and notify online users
2 shutdown command
2.1 sync
· Write data not written to the hard disk in memory to the hard disk
2.2 shutdown
· Shutdown now # shut down immediately
· Shutdown + 2 # shutdown after 2 minutes
· Shutdown: # shutdown
· Shutdown + 2 "The machine will shutdown" # shut down after 2 minutes, and notify online users
2.3 reboot
· Restart. After parameters are added, halt and poweroff can be implemented.
2.4 halt
The link pointing to reboot is equivalent to shutdown-h.
2.5 poweroff
Link to reboot, equivalent to halt
3. execution level
3.1 Classification
· 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. Since linux and windows run many processes in the background, forced shutdown may lead to data loss in the process? Make the system unstable? In some systems, hardware is damaged. And use the shutdown command before the system is shut down? The system administrator notifies all logged-on users that the system will be disabled. And the login command will be frozen? That is, new users cannot log on again. Is it possible to directly shut down or wait for a certain period of time to shut down? It may also restart. This is determined by the signal that all processes receive from the system [signal. Does this allow programs like vi to have time to store the files currently being edited? Programs like mail and news can leave normally"
In addition, shutdown will execute the scripts under/etc/rc0.d/, that is, it will execute the runlevel 0 script. Halt does not.
Poweroff: power off the system
Poweroff is 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? Killing an application process? Execute sync system call? After the file system writes, the kernel is stopped.