1. Shutdown, restart and logout commands
1.1. Shutdown, restart and logout commands
[syntax format]
shutdown [OPTION]... TIME [MESSAGE]
shutdown [option]... time [news]
Parameter description of Shutdown command
Parameter options |
Explanation (focus on those with *) |
-r |
Restart the system instead of shutdown. This parameter is often used in system restart |
-h |
Shutdown: this parameter is often used for system shutdown |
-H |
Shut down (halt). After testing, the system is not completely shut down after using this parameter. It is not commonly used |
-P |
poweroff, not commonly used |
-c |
Canceling the executing shutdown command is rarely used |
-k |
Only send shutdown warning information and refuse new users to log in, but it is not an actual shutdown and is rarely used |
[usage example]
Shut down the system in one minute
[root@web01 ~]# shutdown -h +1 #Shut down the linux system in a minute Broadcast message from root@web01 #Notify all users of shutdown information (/dev/pts/0) at 20:02 ... The system is going down for halt in 1 minute! #Shutdown mode and time prompt ^Cshutdown: Shutdown cancelled #Press Ctrl+c to cancel
11: 00 sharp closing:
[root@web01 ~]# shutdown -r 11:00 Broadcast message from root@web01 (/dev/pts/0) at 20:06 ... The system is going down for reboot in 894 minutes! ^Cshutdown: Shutdown cancelled
Now shut down the system:
[root@web01 ~]# shutdown -h now #Equivalent to init 6
1.2. Shutdown and restart command: halt/poweroff/reboot
[syntax format]
reboot [OPTION]...
halt [OPTION]...
poweroff [OPTION]...
[usage example]
Halt shutdown:
[root@web01 ~]# halt Broadcast message from root@web01 (/dev/pts/0) at 20:19 ... The system is going down for halt NOW!
Halt is the link file of the reboot command. The specific commands are as follows:
[root@client ~]# ls -l /sbin/halt lrwxrwxrwx. 1 root root 6 7 month 5 2016 /sbin/halt -> reboot
Poweroff shutdown command is as follows:
[root@web02 ~]# poweroff Broadcast message from root@web02 (/dev/pts/0) at 20:22 ... The system is going down for power off NOW!
The Poweroff command is also a link file of the reboot command, as follows:
[root@client ~]# ls -l /sbin/poweroff lrwxrwxrwx. 1 root root 6 7 month 5 2016 /sbin/poweroff -> reboot
The Reboot command is used as follows:
[root@web01 ~]# reboot Broadcast message from root@web01 (/dev/pts/0) at 20:25 ... The system is going down for reboot NOW!
1.3 shutdown, restart command and logout command form
command |
explain |
Shutdown command |
|
shutdown -h now |
Turn it off immediately |
Shutdown -h +1 |
Shutdown in 1 minute |
halt |
Stop the system immediately and turn off the power manually |
Init 0 |
Switch to 0 operation level. 0 means shutdown |
poweroff |
Stop the system immediately and turn off the power |
Restart command |
|
reboot |
Restart now |
shutdown -r now |
Restart now |
Init 6 |
Switch to operation level 6, which means restart |
Logout command |
|
logout |
Logout exits the current user window |
exit |
Log off to exit the current user window (Shortcut Ctrl+c) |
1.4 thoughts
If the foundation is not strong, the earth will shake and the mountains will shake! A lot of high technology is accumulated by small basic knowledge!
Linux commands are one of the core and important foundations of the Linux system. Therefore, we should firmly grasp the basic commands in order to do whatever we want when using Linux in the future.