linux shutdown command - Learn to halt, reboot and scheduled halts

The Linux Shutdown command is a command-line tool to brings your system down in a secure way.

You can shut down the system immediately or after a specific interval of time. If you are working on a headless server or you are connected to a remote server through SSH then command-line is the only option for you to shut down your system. When you hit the shutdown command, all logged in users and processes are notified that the system is going down, and no further logins are allowed.

In this tutorial, we will show you how to use the shutdown command to bring down the system in Linux.

Basic Syntax for Linux Shutdown Command

The basic syntax of the Shutdown command is shown below:

shutdown [OPTIONS] [TIME] [MESSAGE]

Where:

  • OPTIONS : Specify the different shutdown options including, halt, poweroff and reboot.
  • TIME : Specify when you want to shut down the system.
  • MESSAGE : Specify the message you want to broadcast to all users.

Detail information of each option available with the shutdown command is shown below:

  • -c
    This option is used to cancel the shutdown process.
  • -r
    This option is used to reboot the system.
  • -h
    This option instructs the system to shut down and then halt.
  • -P
    This option instructs the system to shut down and then power down.
  • -f
    This option skip the filesystem check after reboot.
  • -F
    This option forces the filesystem check after reboot.

You can see the shutdown man page with the following command:

man shutdown

You should see the following screen:

Working with Shutdown command

If Run the shutdown command without any argument, it will power-off the system and not reboot/restart.

shutdown

By default, the power-off process will be initiated in a minute after running the shutdown command.

If you want to power-off the system immediately run the following command:

shutdown -h now

You should see the following output:

Broadcast message from vyom@rsyslog-client
(/dev/pts/19) at 21:28 ...
The system is going down for halt now!

Reboot Linux Command

You reboot the linux by specifying -r option after shutdown as shown below:

shutdown -r now

You should see the following output:

Broadcast message from vyom@rsyslog-client
(/dev/pts/19) at 21:28 ...
The system is going down for reboot now!

Schedule Shutdown and/or Reboot Linux at a Specific Time

You can also shut down and reboot the system at a specified interval of time.

For example, to schedule the system to shut down at 11 A.M by running the following command:

shutdown -h 11:00

You should see the following output:

Broadcast message from vyom@rsyslog-client
(/dev/pts/19) at 21:45 ...
The system is going down for halt in 795 minutes!

To schedule the system to reboot at 7 A.M by running the following command:

shutdown -r 7:00

You should see the following output:

Broadcast message from vyom@rsyslog-client
(/dev/pts/19) at 21:47 ...
The system is going down for reboot in 553 minutes!

To schedule the system to shut down after 20 minutes with a warning message by running the following command:

shutdown -h +20 "System will be shutdown for upgrading hardware"

You should see the following output:

Broadcast message from vyom@rsyslog-client
(/dev/pts/19) at 21:49 ...
The system is going down for halt in 20 minutes!
System will be shutdown for upgrading hardware

Cancel Linux Shutdown Operation

If you schedule the system to shut down at a specific time and want to cancel the shutdown process within the time mentioned in the shutdown command, run the shutdown command with -c option:

For example, open the first terminal and schedule the system to shut down after 10 minutes with the following command:

shutdown -h +10

Next, open the second terminal and cancel the shutdown operating with the following command:

shutdown -c

You should see the following output on the first terminal:

Broadcast message from vyom@rsyslog-client
(/dev/pts/19) at 21:59 ...
The system is going down for halt in 10 minutes!
shutdown: Shutdown cancelled

Conclusion

As you see, there are several ways to shut down the system using the Linux Shutdown Command. Using this command with different options can perform shutdown, reboot, halt and poweroff your system.