The Shutdown command is a program written in the shell that must be performed by the superuser. After the shutdown command executes, all users working in the system are notified as broadcasts, and the system shuts down within the specified time, when the login instruction is frozen and the new user cannot log on. When all users log off from the system or the specified time has elapsed, shutdown sends a signal to the INIT program, requiring the INIT program to change the operating level of the system. The INIT program then changes the run level according to the parameters passed by the shutdown instruction. For example, the INIT program shuts down the init 0 when the parameter specified by shutdown is the shutdown command, and the INIT program executes INIT 6 for system restart if the parameter specified by shutdown is to reboot the system.
Sync synchronizes data from memory to hard disk before shutting down
shutdown command verbose syntax shutdown [-FFHKNRC] [-t seconds] time [warning message]-f: Do not perform fsck when restarting. "Fsck is the next program to check and repair the file system on Linux"-F: Perform fsck on reboot, default to Big f-h: Shut down the system, in a certain function, equivalent to the halt command.- k: Just send out information to all users, but not really shut down. -N: Do not call the INIT program shutdown, but by the shutdown itself (the general shutdown program is called by shutdown Init to implement the shutdown action), using this parameter will speed up the shutdown, but it is not recommended to shut down in this way. Restart the system after-r:shutdown.- C: Cancels the previous shutdown command. For example, when executing a command such as "Shutdown-h 15:30" as long as the "CTRL + C" key combination will be able to shut down the terminal command, and perform such as "Shutdown-h 15:30 &" command, will shutdown to the background to run, you need to use "Shutdown-c" cancels the previous shutdown command. -t< seconds;: How many seconds to delay between sending the warning message and shutting down the signal. The warning message will alert the user to save the current work. [TIME]: Set how long after the shutdown command is executed. The time parameter has hh:mm or +m two modes.[WARNING message]: information to be transmitted to all logged-in users. Application Examples:shutdown-h Shutdown InstructionsShutdown-h now immediately shuts down Shutdown-h 20:25 system will shut down at 20:25 today Shutdown-h 10This command broadcast tells you that the computer will shut down after 10 minutes and will be displayed in the current screen of the logged-on user. Only you can cancel at other terminals. The Cancel command does not broadcast after the terminal that sent the shutdown command cancels the command.
shutdown-r Restart Command
Shutdown-r now system immediately restarts Shutdown-r 10 system restart after 10 minutes
reboot is a reboot, equivalent to Shutdown-r now
In conclusion, whether it is rebooting the system or shutting down the system, first run the sync command to write the data in memory to disk. Commands to shut down have shutdown-h now, halt, Poweroff and init 0 reboot system commands have shutdown-r now, reboot, Init 6.
From for notes (Wiz)
Shutdown shutdown Instructions