The shutdown command under the Linux system is used to safely shut down/Restart the computer, it can not only conveniently implement the timer shutdown, but also can be determined by the user when the relevant parameters of the shutdown. When executing the shutdown command, the system sends a screen display to each terminal (user), prompting the shutdown operation. Timed shutdown requires only a simple parameter, which can be a countdown or an exact time.
Command format
1 |
shutdown [选项] [时间] [消息] |
and have the following options:
-K do not perform any shutdown operation, only send warning message to all users
-R Restart the computer
-H shutdown and power off completely
-F Fast Shutdown and skip fsck at restart
-N Fast shutdown without init program
-C Cancel the pre-timer shutdown
Real-World Application examples
Turn off the machine now
Shutdown-h now
Restart now
Shutdown-r now
Note that now cannot be omitted here, and is considered a special use.
Timer shutdown
If there are other commands to perform after 5 minutes of scheduled shutdown, or if you want to place a timed shutdown command in the background:
Shutdown-h +5 &
Then press ENTER several times to continue using the terminal to perform other operations. If you want to terminate the 5-minute shutdown performed above, execute:
Shutdown-c
Can.
If the shutdown is only scheduled for 5 minutes and no other command is executed, the direct:
Shutdown-h +5
At this point, if you want to cancel the timer shutdown, press CTRL + C to force the termination of the command.
To shut down the computer at 20:13:
Shutdown-h 20:13
Note: Only users with super administrative privileges can use this command, and ordinary users do not have permission to execute the command. If a normal user executes the command, you may be prompted
1 |
bash: shutdown : command not found . |
This occurs because of an environment variable problem with an ordinary user that prevents the shutdown program from being found properly. If you use the "su" command, be aware that the ENV environment variable is also switched to the root account, otherwise it may still be problematic.
The shutdown command under the Linux system is used to safely shut down/restart the computer