Linux Shutdown Command Explained (with Examples)

Do you need to know how to shut down your Linux system using the command line or schedule a shutdown at a specific time? Here's the answer!

The shutdown command in Linux brings the system down in a secure way. This involves cutting the power to the main components of the system using a controlled process. 

The command allows you toย shut down the system immediatelyย orย schedule a shutdown using the 24-hour format.

When the shutdown is initiated, the signal SIGTERM notifies all logged-in users and processes that the system is shutting down. In addition, no other logins are allowed.

It’s important to mention that only root or user with sudo privileges can execute the shutdown command.

Below is the shutdown command syntax in Linux:

shutdown [OPTIONS] [TIME] [MESSAGE]Code language: CSS (css)
  • OPTIONS โ€“ Shutdown options such as halt, power-off, or reboot the system.
  • TIME โ€“ Specifies when to perform the shutdown process.
  • MESSAGE โ€“ Specifies a message which will be broadcast to all users.

The primary usage is easy. All you have to do is to run the shutdown command.

sudo shutdown
Linux shutdown Command Without Options

As you can see from the image above, the command will not shut down your Linux system immediately.

However, if no time argument is specified, +1 is implied, which means the shutdown process will be initiated in a minute from now, which is the default time interval.

How to Shutdown Linux System Immediately

To immediately shut down the system, you can use +0 or its alias now after the shutdown command:

sudo shutdown now

How to Schedule Shutdown at Specific Time in Linux

Linux shutdowns can also be easily scheduled to occur after a particular time or at a specific time.

The time argument can have two different formats. For example, it can be an absolute time in the format hh:mm or relative time in the format +m, where m is the number of minutes from now.

For example, if you want to schedule a shutdown at 10 AM, then use the following:

sudo shutdown 10:00Code language: CSS (css)
Schedule Shutdown at Specific Time in Linux

It’s important to remember that the Linux shutdown command follows a 24 hours format. Therefore, to schedule the system to shut down at 10 PM:

sudo shutdown 22:00Code language: CSS (css)
Schedule Shutdown at Specific Time in Linux

Let’s now schedule a system shutdown for 30 minutes from now:

sudo shutdown +30
Schedule Shutdown at Specific Time in Linux

How to Broadcast a Custom Message

To show the message to the people logged in to your server before the server goes down, type your message after the time argument.

The following example will shut down the system 20 minutes from now and notify the users that a system upgrade will be performed:

sudo shutdown +20 "System upgrade in 20 minutes. Save your work."Code language: JavaScript (javascript)

The above command shall flash the message to all other logged-in users and give them 20 minutes before the system shutdown.

How to Restart Linux System Immediately Using the shutdown Command

To restart your Linux system safely, use the following command below:

sudo shutdown -r now

The -r option, which stands for a reboot, requests that the system be rebooted after being brought down.

How to Schedule Restart at Specific Time Using the shutdown Command

Just like a shutdown, a restart can also be scheduled. For example, to schedule a restart for your system at 10 PM:

sudo shutdown -r 22:00Code language: CSS (css)
Schedule Restart at Specific Time in Linux

To schedule a system restart 30 minutes from now:

sudo shutdown -r +30
Schedule Restart at Specific Time in Linux

Canceling the Shutdown

The scheduled shutdown can be canceled anytime using the -c argument:

sudo shutdown -c

The command will immediately cancel the specified scheduled time of shutdown or restart. Keep in mind that this command cannot be used if you are immediately shutting down your system with the now or +0 expression.

How Do I Check My Scheduled Shutdown in Linux?

You are probably asking yourself: Is there any way to check if a shutdown countdown has been activated? Yes, this can be achieved by using the command below:

date -d @`cat /run/systemd/shutdown/scheduled | head -n 1 | cut -c6-15`Code language: JavaScript (javascript)

For example, if you set your Linux system to be shutting down at 10 PM (sudo shutdown 22:00), the output of the above command will be:

Check Scheduled Shutdown in Linux

I agree, it’s probably not the most elegant solution, but it does the job.

Conclusion

I hope this article helped you learn how to use the Linux shutdown command and its options. On top of that, it is also an efficient and risk-free method of shutting down all processes and the system’s power.

Please find out more about various options in the shutdown command on its command line manual page.

If you have any questions or feedback, feel free to leave a comment.

Bobby Borisov

Bobby Borisov

Bobby, an editor-in-chief at Linuxiac, is a Linux professional with over 20 years of experience. With a strong focus on Linux and open-source software, he has worked as a Senior Linux System Administrator, Software Developer, and DevOps Engineer for small and large multinational companies.

Think You're an Ubuntu Expert? Let's Find Out!

Put your knowledge to the test in our lightning-fast Ubuntu quiz!
Ten questions to challenge yourself to see if you're a Linux legend or just a penguin in the making.

1 / 10

Ubuntu is an ancient African word that means:

2 / 10

Who is the Ubuntu's founder?

3 / 10

What year was the first official Ubuntu release?

4 / 10

What does the Ubuntu logo symbolize?

5 / 10

What package format does Ubuntu use for installing software?

6 / 10

When are Ubuntu's LTS versions released?

7 / 10

What is Unity?

8 / 10

What are Ubuntu versions named after?

9 / 10

What's Ubuntu Core?

10 / 10

Which Ubuntu version is Snap introduced?

The average score is 68%