Required Linux shutdown/restart command
Address: http://www.360doc.com/content/10/0818/22/935385_47061591.shtml
Abstract: To learn more about Linux, you should first learn from the basics. Now, many people are learning about Linux. To learn about Linux, you must first understand some Linux commands. This article introduces the knowledge of Linux shutdown/restart commands. Common Linux shutdown/restart Commands include shutdown, halt, reboot, and init.
To learn more about Linux, you must start with basic learning. Now, many people are learning Linux. To learn about Linux commands, you must first learn about Linux commands. This article describes how to shut down or restart Linux commands. Common Linux shutdown/restart Commands include shutdown, halt, reboot, and init, which can 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 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 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 programs such as VI to have time to store the files being edited, while programs such as mail and news can leave 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], runlevel 6 is used to reactivate the [reboot] system, and runlevel 1 is used to bring the system into the state where management can be done. This is the preset state. if no-H or-R parameter is set to shutdown. If you want to know what actions are performed during the shutdown (halt) or re-boot (reboot) process, you can view the runlevels related information in the/etc/inittab file.
Shutdown parameter description:
[-T] before changing to another runlevel, tell init how long it will take to shut down.
[-R] restart the calculator.
[-K] does not actually shut down, but sends a warning signal to each consumer [Login 〕.
[-H] power off after Shutdown [halt 〕.
[-N] shut down by yourself instead of init. You are not encouraged to use this option, and the consequences of this option are not always what you expected.
[-C] cancel current process cancels the currently running Shutdown program. Therefore, this option certainly does not have a time parameter, but you can enter a message for explanation, and this information will be sent to each user.
[-F] Ignore fsck when restarting calculator [reboot.
[-F] forces The fsck when restarting the calculator [reboot.
[-Time] set the time before shutdown.
Shutdown exampleShutdown now: # shutdown-H now: shutdown after 5 minutes, and send a warning message to the Login User: # shutdown + 5 "system will shutdown after 5 minutes"
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.
Parameter description:
[-N] prevents the sync system from calling. 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 superblock.
[-W] is not a real restart or shutdown, but a record for wtmp (/var/log/wtmp.
[-D] Do not write the wtmp record [included in Option [-N 〕.
[-F] Force shutdown or restart without calling shutdown.
[-I] disable all network interfaces before shutting down (or restarting.
[-P] this option is the default option. It is called poweroff when shutdown.
Halt exampleTurn off the power after halt-P shuts down the system.
Halt-D shut down the system, but no record is left.
3. Reboot
The reboot process is similar to that of halt, but it causes host restart, while halt is shutdown. Its parameters are similar to those of halt. // What is the difference between halt and halt? One is shutdown and the other is restart;
Reboot BasicsFunction Description: restart the instance.
Syntax: dreboot [-dfinw]
Note: executing the reboot command can stop the system and restart it.
Parameters:
-D do not write data into the record file/var/tmp/wtmp upon re-boot. This parameter has the effect of the "-n" parameter.
-F force reboot without calling the shutdown command.
-I disable all network interfaces before restarting the instance.
-N do not check whether there are unfinished programs before the reboot.
-W is only used for testing. It does not really restart the system. It only writes the data that is restarted to the wtmp record file in the/var/log directory.Reboot example
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. I will not describe it here for a long article on init. In addition, the telinit command can change the running level of init. For example, telinit-Is can enable the system to enter the single-user mode, and the information and waiting time when shutdown is not available.
The above is an introduction to Linux shutdown/restart commands.