Commonly used shutdown/restart commands in Linux include shutdown, reboot, init, halt and poweroff. They can all achieve the purpose of restarting the system, but the internal working process of each command is different. The following article will introduce these commands to you. I hope it will be helpful to you. [Video tutorial recommendation: linux tutorial]
1. shutdown command
shutdown command is the most commonly used It is also the safest shutdown and restart command. It will call fsck to check the disk before shutting down. -h and -r are the most commonly used parameters:
● -h: Stop the system service and shut down
● -r: Stop the system service and then restart it
Example:
shutdown -h now --立即关机 shutdown -h 10:53 --到10:53关机,如果该时间小于当前时间,则到隔天 shutdown -h +10 --10分钟后自动关机 shutdown -r now --立即重启 shutdown -r +30 'The System Will Reboot in 30 Mins' --30分钟后重启并并发送通知给其它在线用户
2. Reboot command
reboot means restart immediately, the effect is equivalent to shutdown -r now
.
3. init command
init is the ancestor of all processes. Its process number is always 1, so sending the TERM signal to init will terminate all user processes. daemon process etc. shutdown uses this mechanism.
init defines 7 runlevels:
init 0
means shutdown or shutdown (never set initdefault to 0 ),
init 1
is single-user mode, and only the root user performs maintenance.
init 2
- Multi-user, no NFS, no network
init 3
- Complete Multi-user mode (standard run level)
##init 4 - not used
init 5 - X11 (xwindow) graphical interface mode
init 6 - Restart (do not set initdefault to 6)
4. Halt command
The halt command is the simplest shutdown command, which is actually callingshutdown -h. When halt is executed, it ignores the current system status and performs a hardware shutdown; kills the application process, executes the sync system call, and stops the kernel after the file system write operation is completed.
5. Poweroff command
poweroff means immediate shutdown, the effect is equivalent toshutdown -h now, in multi-user mode (Run Level 3 )Not recommended for use.
The above is the detailed content of What is the linux server restart command?. For more information, please follow other related articles on the PHP Chinese website!