Common shutdown/Restart commands under Linux typically include:
Shutdown, reboot, Halt, Poweroff and so on, of course we can use Init run level RunLevel 0 that is halt to shut down, or use init run level RunLevel 6 that is reboot to perform a reboot.
Of course, there are some subtle differences in the way these shutdowns or restarts are made.
First, make clear that the RunLevel operating level of the Linux/redhat system is different from the runlevel of the Debian system.
The runlevel of the Redhat system is defined as follows:
RunLevel 0:halt system down state, the default operating level of the system cannot be set to 0, otherwise it will not start normally
RunLevel 1:single User single users working status, root privileges, for system maintenance, prohibit remote login
RunLevel 2:multiuser without network multi-user state (no NFS)
Runlevel3:multiuser full multiuser State (with NFS), enter console command line mode after login
Runlevel4:unuse system not used, reserved
runlevel5:x11 X11 Console, enter GUI mode after login
Runlevel6:reboot system shutdown and restart, the default run level cannot be set to 6, otherwise it will not start normally
In Debian/ubuntu, RunLevel is defined as:
0-halt
1-single
2-full Multi-User with Display Manager (GUI)
3-full Multi-User with Display Manager (GUI)
4-full Multi-User with Display Manager (GUI)
5-full Multi-User with Display Manager (GUI)
6-reboot
You can see that there is no difference in the 2~5 level.
Ubuntu system has a default runlevel of 2.
Therefore, we can perform the halt shutdown using init, and execute the reboot using init 6来.
In fact, the shutdown command is also done after a series of operations, such as closing the process/service one by one, call sync to write data to disk, and then call Init0 or INIT6 to perform shutdown or restart.
And halt is actually called shutdown-h now, can ignore the system's current state and directly shut down, but in some systems, halt will not power off, and only shut down the OS.
Here's a brief summary of how these commands are used.
"2016-10-11" Linux systems common shutdown or restart commands shutdown, reboot, Halt, Poweroff, Init 0, and init 6 connections and differences