Home >Operation and Maintenance >Linux Operation and Maintenance >What are the linux restart commands?
Linux restart command: 1. Shutdown command, enter "shutdown -r now" to restart immediately, "shutdown -r 10" to automatically restart after 10 minutes; 2. Reboot command, directly enter "reboot" You can restart; 3. Init command, enter "init 6" to restart.
Recommended related articles: linux tutorial
Some commonly used shutdown methods under Linux/ Restart commands include shutdown, halt, reboot, and init. They can all achieve the purpose of restarting the system, but the internal working process of each command is different.
shutdown
# The shutdown command safely shuts down the system. Some users will use the method of directly cutting off the power to shut down Linux. This is very dangerous. Because Linux is different from Windows, there are many processes running in the background, so forced shutdown may cause the data of the process to be lost, put the system in an unstable state, and even damage the hardware equipment in some systems. If you use the shutdown command before shutting down the system, the system administrator will notify all logged-in users that the system will be shut down. And the login command will be frozen, that is, new users can no longer log in. It is possible to shut down directly or delay the shutdown for a certain period of time, and it is also possible to restart. This is determined by the fact that all processes receive signals sent by the system.
shutdown -r now //立刻重启(root用户使用) shutdown -r 10 //过10分钟自动重启(root用户使用) shutdown -r 20:35 //在时间为20:35时候重启(root用户使用)
Shutdown performs its job by sending a signal to the init program and asking it to change the runlevel.
Parameter description:
[-t] Tell init how long to shut down before changing to other runlevels.
[-r] Restart the calculator.
[-k] does not actually shut down, but only sends a warning signal to each login [login].
[-h] Turn off the power after shutdown [halt]
[-n] Do not use init, but shut down by yourself. Using this option is discouraged, and the consequences of this option are not always what you expect.
[-c] cancel current processCancel the shutdown program currently being executed. So of course this option has no time parameter, but you can enter an explanatory message and this message 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].
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 is stopped after the file system write operation is completed.
Parameter description:
[-n] Prevent sync system call, which is used after patching the root partition with fsck to prevent the kernel from using the old version of the super block [-n] superblock] overwrites the patched superblock.
[-w] is not a real restart or shutdown, it just writes wtmp [/var/log/wtmp] records.
[-d] Do not write wtmp records [included in option [-n]].
[-f] Force shutdown or restart without calling shutdown.
[-i] Before shutting down (or restarting), turn off all network interfaces.
[-p] This option is the default option. Just call poweroff when shutting down.
reboot
The working process of reboot is almost the same as halt, but it causes the host to restart, while halt is to shut down. Its parameters are similar to halt.
init
Syntax: init (option) (parameter)
Parameter description
-b: Enter single-user mode directly without executing relevant scripts;
-s: Switch to single-user mode.
0 Shutdown (never set initdefault to 0)
1 Single-user mode
2 Multi-user, no NFS (similar to level 3, some services will be stopped) )
3 Full multi-user mode
4 Not used
5 x11(Xwindow)
6 Restart (never set initdefault to 6)
Related learning recommendations: linux video tutorial
The above is the detailed content of What are the linux restart commands?. For more information, please follow other related articles on the PHP Chinese website!