Table of Contents
Shutdown Command in Linux
The shutdown command is used to bring the system down in a secure way. When the process is initialized, all the users are notified that the system is going down instantly or after some time. By using shutdown command you can make the system down on a specific time. In this tutorial, you are going to learn how to use shutdown command in Linux.
The basic syntax for the shutdown command
Before you learn how to use shutdown utility in Linux, you should know the basic syntax of shutdown command.
Following is the basic syntax for shutdown command:
shutdown [OPTIONS] [TIME] [MESSAGE]
OPTIONS: Options like Halt, Reboot, etc. are used.
--help: Displays short help text.
-H or --halt: This option is used to Halt the machine.
-r or --reboot: To reboot the machine.
-c: Cancel the shutdown.
-P or --poweroff: This is the default option to the power of the machine.
TIME: When to perform the shutdown process.
MESSAGE: This message will broadcast to all the users at the time of performing the shutdown process.
How to use the shutdown
When a shutdown command is used without any option, It will power-off the machine.
Following is the basic command to shut down the machine:
After executing the above command system will shut down after 1 minute which is default delay time.
The output should look like:
Shutdown scheduled for Wed 2019-01-23 10:16:07 IST, use 'shutdown -c' to cancel.
Shutdown system instantly
As the default delay interval for shutdown command is 1 minute but if you want to shutdown system immediately the use
now as the time argument.
By running following shutdown command in linux you can shutdown machine immediately:
sudo shutdown now
How to Broadcast a Custom Message
You can broadcast a message to all the users when performing the shutdown process specifying message after time argument. It is always important to specify the
time argument when broadcasting the message.
Following command is used to shutdown machine after two minutes with the message “System Upgrade”:
sudo shutdown +2 "System Upgrade"
How to cancel the shutdown in Linux
What if you have already scheduled shutdown and you want to cancel it. By using
-c option you can cancel shutdown immediately.
To cancel shutdown run following command.
sudo shutdown -c
You can also broadcast a message when canceling the shutdown.
sudo shutdown -c "Shutdown canceled"
How to shutdown the system at a specific time
hh:mm relative time and
+m number of minutes are used to specify the time with the shutdown command. By using these formats you can schedule a shutdown at a specific time.
To schedule a shutdown at
10:00 AM run following command:
sudo shutdown 10:00
To schedule shutdown after 30 minutes from now, use the following shutdown command in Linux system terminal:
sudo shutdown +30
You can also broadcast a message with the shutdown command in the following way:
sudo shutdown 10:00 "Hardware Upgrade"
How to reboot the machine
-r the option you can reboot the machine.
To reboot the system run below shutdown command in Linux:
sudo shutdown -r
To reboot the system at
10:00 AM run following command:
sudo shutdown 10:00 "System Upgrade"
How to halt the machine
By using the
-H option you can halt the machine.
To reboot the system run below command:
sudo shutdown -H
You have successfully learned how to use shutdown command in Linux. If you have any queries regarding this then please don’t forget to comment below.