How to use Linux Shutdown Command with Examples

July 5, 2020

Introduction

All Linux users and system administrators need to know how to shut down the entire system safely. There are several options to do so, including scheduling a shutdown at a specific time, shutting down immediately, broadcasting a unique message, and so on.

In this tutorial, learn how to use the Linux shutdown command with examples.

linux tutorial on the shutdown command with options

shutdown Command Syntax

Before going into specific ways to shut down your Linux system, you should understand the basic syntax of the shutdown command:

shutdown [options] [time] [message]
  • [options] define whether you want to halt, power-off, or reboot the machine.
  • [time] specifies when you want the shutdown to perform.
  • [message] adds a message that announces the shutdown.

Note: If you need to reboot instead of shut down the system, refer to How To Restart Or Reboot Linux Server From The Command Line.

How to Use the shutdown Command

To use the shutdown command on Linux systems, a  root user or a user with sudo privileges is required.

If you use the command without additional arguments, running sudo shutdown in a terminal window executes the shutdown in 60 seconds.

In the image below, see the output received after running the shutdown command.

Running the shutdown command in a Linux system

Shutdown With All Parameters

To view all parameters when shutting down the Linux system, use the following command:

sudo shutdown --help

The output displays a list of shutdown parameters, as well as a description for each.

List shutdown command with all parameters.

How to Shut Down the System at a Specific Time

To schedule a shutdown, add the [time] argument and specify when you want it to take place. There are two ways to shut down the system at a specific time – using the absolute or relative time format.

The absolute time follows the format hh:mm and allows you to schedule a shutdown at a specified time. The command follows the syntax:

sudo shutdown hh:mm

For example, to require a shutdown at 7 AM in the morning, the command is:

sudo shutdown 07:00
Schedule system shutdown at a specific time in Linux.

Alternatively, use the relative format (+m) and schedule a shutdown in a defined number of minutes from the time you run the command. In that case, the command syntax is:

sudo shutdown +m

To shut down the system in 20 minutes, run:

sudo shutdown +20
Schedule a system shutdown in the specified number of minutes.

How to Shut Down the System Immediately

As previously mentioned, running the shutdown command without any arguments prompts the system to shut down a minute after running the command. However, if you require an immediate shutdown, use:

sudo shutdown now

Another option would be to schedule a shutdown using the relative time format with the value 0, as in the command below:

sudo shutdown +0

How to Broadcast a Custom Message

Once you schedule a system shutdown, all users within the system receive a message notifying them of the shutdown. To add a custom message to the shutdown notification to inform the users what is about to take place.

You can add a [message] only if the command also includes the [time] attribute:

sudo shutdown [time] "[message]"

For instance, to shut down the system in 20 minutes and broadcast the message System Upgrade, run:

sudo shutdown +20 "System Upgrade"
Set broadcast message for a system shutdown in Linux.

Note: Another way to broadcast messages to users in Linux is via the wall command.

How to Cancel a Scheduled Shutdown

To cancel a scheduled shutdown, use the command:

sudo shutdown -c

You can also add a message to notify users that the shutdown is canceled. To do so, add the [message] option (within quotations) to the command above. For example:

sudo shutdown -c "Canceling System Upgrade"

Conclusion

This article includes all the basic shutdown commands every Linux user should know. Utilizing this command is a safe way to shut down your system. Also, it is a useful method of informing all users about scheduled shutdowns.

Was this article helpful?
YesNo
Sofija Simic
Sofija Simic is an experienced Technical Writer. Alongside her educational background in teaching and writing, she has had a lifelong passion for information technology. She is committed to unscrambling confusing IT concepts and streamlining intricate software installations.
Next you should read
How to Start, Stop, and Restart Services in Linux
March 27, 2024

In most modern Linux operating systems, managing a service is quite simple when it comes to basic commands...
Read more
Linux Commands Cheat Sheet: With Examples
November 2, 2023

A list of all the important Linux commands in one place. Find the command you need, whenever you need it or...
Read more
How to Delete Line in Vim on Linux
April 22, 2020

Vim allows you to delete entire lines, words or characters using various Vim commands. Learn the most...
Read more
How to Get the Size of a Directory in Linux
February 8, 2024

Use the command line interface to display directory size and for display disk space. This guide will help you...
Read more