How to Use Shutdown Command in Linux

How to Use Shutdown Command in Linux
How to Use Shutdown Command in Linux

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 system down on the specific time. In this tutorial, you are going to learn how to use shutdown command in Linux.

Basic syntax for 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]

Where,
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 default option to 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 shutdown

When shutdown command is used without any option, It will power-off the machine.

Following is the basic command to shutdown the machine:

sudo shutdown

After executing above command system will shutdown 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 command 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 always important to specify 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

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 system at a specific time

Two formats hh:mm relative time and +m number of minutes are used to specify the time with shutdown command. By using these formats you can schedule a shutdown at spefic 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 command:

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

By using -r option you can reboot the machine.

To reboot the system run below command:

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 -H option you can halt the machine.

To reboot the system run below command:

sudo shutdown -H

Conclusion

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.