Detailed Linux shutdown command

  
                  1. The shutdown shutdown command safely shuts down the system. Some users will shut down Linux by directly disconnecting the power supply, which is very dangerous. Because linux and windows are different, there are many processes running in the background, so forcible shutdown may result in data loss of the process, making the system unstable, and even in some systems, the hardware device will be damaged. Using the shutdown command before the system is shut down, the system administrator will notify all logged-in users that the system will be shut down. And the login command will be frozen, ie the new user can no longer log in. It is possible to shut down directly or delay the system for a certain period of time, and it may be restarted. This is determined by all the processes that receive the signal from the system. This allows programs like vi to have time to store documents that are currently being edited, while programs like mail and news can leave normally. The shutdown to perform its job is to send a signal to the init program, asking it to change the runlevel. Runlevel 0 is used to stop [halt], runlevel 6 is used to reactivate the [reboot] system, and runlevel 1 is used to get the system into a state where management can be performed; this is preset, assuming no -h There is also no -r parameter for shutdown. To find out what actions have been taken during a halt or reboot, you can see these runlevels related information in this file /etc/inittab. Shutdown parameter description: [-t] Before changing to other runlevels, tell init how long to shut down. [-r] Restart the calculator. [-k] does not really shut down, just send a warning signal to each login [login]. [-h] Turn off the power [halt] after turning off the power. [-n] Instead of init, shut yourself down. This option is discouraged and the consequences of this option are often not always what you expect. [-c] cancel current process Cancel the shutdown program currently being executed. So of course this option has no time parameters, but you can enter a message for explanation, and this information will be sent to each user. [-f] Ignore fsck when restarting the calculator [reboot]. [-F] Force fsck when restarting the calculator [reboot]. [-time] Set the time before shutdown [shutdown]. 2.halt----the simplest shutdown command In fact, halt is to call shutdown -h. When halt is executed, the application process is killed, the sync system call is executed, and the kernel system stops when the file system write operation is completed. Parameter Description: [-n] Prevents the sync system call. It is used to fix the root partition with fsck to prevent the kernel from overwriting the repaired super block with the old version of the superblock. [-w] is not a real reboot or shutdown, just write wtmp[/var/log/wtmp] records. [-d] Do not write wtmp records (included in option [-n]). [-f] Forced shutdown or restart without calling shutdown. [-i] Turn off all network interfaces before shutting down (or restarting). [-p] This option is the default option. It is to call poweroff when shutting down. 3. The process of reboot reboot is almost the same as that of halt, but it causes the host to restart, and the halt is shutdown. Its parameters are similar to those of halt. 4.init init is the ancestor of all processes, its process number is always 1, so sending a TERM signal to init will terminate all user processes, daemons and so on. Shutdown is to use this mechanism. Init defines 8 runlevels, init 0 is shutdown, and init 1 is restart. About init can be a long story, and will not be described here. In addition, the telinit command can change the running level of init. For example, telinit -iS can make the system enter single-user mode, and can not get the information and waiting time when using shutdown.
Copyright © Windows knowledge All Rights Reserved