Linux Shutdown Command – 8 Examples with All Options

Last updated: June 14, 2022

In some cases, you must shut down or reboot your computer to apply updates, install a new application, migrations, or perform other operations. Linux provides the shutdown command to securely stop all the running processes on your server and to notify all the logged-in users about the shutdown operation.

In this tutorial, we will learn how to use the Linux shutdown command-line utility with practical examples.

Linux Shutdown Command

The shutdown command is used to securely shut down the system. Use this command in Linux for system shutdown either immediately or at a specific time. Shutdown can also be used to reboot your computer system.

When you run the Linux shutdown command-line tool, then all running applications are closed, active system processes are saved, and all currently logged-in users are notified about the shutdown operation. This command also prevents new users from logging in after the shutdown process starts.

Syntax

The basic syntax of this command is as follows:

shutdown [option] [time] [message]

Where:

  • option denotes the operation that you want to perform, such as power-off (default option), halt, or reboot.
  • time denotes when to execute the command. You can use this parameter to schedule a shutdown or reboot.
  • message denotes a comment or message that you want to broadcast to all the logged-in users.

Useful Shutdown Commands

Shutdown provides several options and variations that you can use to perform different options. The following table lists some of the most useful shutdown commands:

CommandsDescription
shutdownShuts down the computer in one minute.
shutdown -hHalts and turns off the system.
shutdown -rReboots the system in one minute.
shutdown -h <time>Halts and turns off the system at a specified time.
shutdown nowShuts down your computer immediately.
shutdown -r <time>Reboots the system at a specified time.
shutdown -r nowReboots the system immediately.
shutdown -PBrings down the system and then powers it off.
shutdown -cCancels a scheduled shutdown.

How to Use Linux Shutdown Command

The following examples show you some of the most common usages of Linux shutdown command:

1. Shutdown After 1 Minute

This is the default behavior of the shutdown command. Use shutdown without any options to shut down the system after one minute:

sudo shutdown
linux shutdown default command

2. Shutdown Now

To do an immediate shutdown, use the Linux shutdown command with now option.

sudo shutdown now

Instead of using the time to now, you can use +0 time option to down the system immediately.

sudo shutdown +0

On a systemd based Linux Distributions the shutdown now equivalent command is systemctl poweroff. In those systems, shutdown command is a symbolic link systemctl.

3. Shutdown at a Specified Time

Use the time argument with the shutdown command to turn off your computer at a specified time. The time argument can be used in two formats- specified time of the day in HH:MM format or +m where you can specify the number of minutes from the current time when the shutdown process will start.

To shut down the system at 10 AM, specify the time after the shutdown command:

sudo shutdown 10:00
shutdown specific time linux

To shut down your computer after five minutes from the current time, specify the five minutes in +5 format:

sudo shutdown +5
shutdown after a specific time Linux

4. Shutdown Message

System administrators can notify users with a warning message about the system shut down.

To shutdown the system in 30 minutes with a broadcast message, use the following command:

sudo shutdown +30 "System is going under maintenance in 30 minutes"
shutdown message Linux

5. Cancel a Scheduled shutdown

There may be a situation where you must cancel a scheduled shutdown. For example, suppose there is a planned release and you need to hold off the shutdown. In that case, you can cancel it using the -c option with the shutdown command and can also specify a custom wall message:

sudo shutdown -c "Ops needs the scheduled shutdown"

This command does not show any output on the screen.

Unfortunately in systemd system the systemctl command doesn't have a schedule or cancel the shutdown. Another option is to add cron to /run/systemd/shutdown/scheduled script.

6. Shutdown command to reboot

By default, the shutdown -r command reboots your system after one minute. To shutdown immediately and automatically reboot your system use the following command:

sudo shutdown -r now

7. Shutdown command to Schedule a Reboot

To schedule a reboot, use the time parameter with the following command as you do with the system shutdown:

sudo shutdown -r +10 “Rebooting for maintenance”
Using shutdown command to schedule a Linux system reboot

Shutdown Help

The shutdown command provides a help page that you can refer to know more about the shutdown command options:

sudo shutdown --help
Linux shutdown help command

Linux Shutdown Command Options

The following table some of the useful options that you can use with the shutdown command:

OptionsDescription
-rBrings down your system and requests for a system reboot.
-hSends a request to either halt or power off the system after bringing the system down.
-HSends a request to halt the system after bringing the system down.
-PSends a request to power off the system after bringing the system down.
-cCancels any scheduled shutdown. You can not specify a time with this option, but you can broadcast a custom message for the system users.
-kSends a warning message to the users and disables all system logins. It does not bring the system down.

Conclusion

In this tutorial, we learned how to use the shutdown command to power down or reboot your Linux system. Shutdown provides various options that you can use to either shut down your system immediately or schedule a shutdown. This command can also be used to reboot your system. You can try these command options and examples in a test environment, but you should use them carefully in a production environment.

About The Author

Subhash Chandra

Subhash Chandra

Subhash Chandra is a professional writer and an Oracle-certified Database Administrator with over 15 years of writing experience. He has a passion for technology and loves to write how-to articles for Linux, Windows, Mac OS, Networking, Telecom, and Database. In his spare time, he enjoys swimming and playing table tennis.

SHARE

Comments

Please add comments below to provide the author your ideas, appreciation and feedback.

Leave a Reply

Leave a Comment