Sep 15, 2023 3 min read

How to Use Linux Shutdown Command

Use the Linux Shutdown Command with our step-by-step tutorial. The shutdown command helps in bringing down the system in the most secure way.

Use Linux Shutdown Command
Table of Contents

Before we begin talking about how to use Linux Shutdown Command, let's briefly understand - What is a Shutdown command?

The shutdown command helps in bringing down the system in the most secure way. As soon as the shutdown command is initiated, all the logged-in users and processes are notified that the system is going down, and they won't be able to log in. You can even shut down your system immediately or schedule the shutdown using the 24-hour format.

Only root users can execute the shutdown command.

In this tutorial, you will use Linux Shutdown Command. We will also address a few FAQs on how to use Linux Shutdown Command.

Syntax of Shutdown Command

Let's review the basic syntax of the shutdown command:

shutdown [OPTIONS] [TIME] [MESSAGE]
  • options: It has shutdown options like halt, power-off (default option), and reboot system.
  • time: It specifies the time at which you want to execute the shutdown process.
  • message: It specifies the message which will be broadcast to all the users.

Options

-r: It sends a request to reboot the system after the system has been brought down.

-h: It sends a request to either halt or power off after the system has been brought down.

-H: It sends a request to halt after the system has been brought down.

-P: It sends a request to power off the system after it has been brought down.

-c: It sends a request to cancel a running shutdown. It doesn't take time as an option.

-k: It only sends the warning option and disables user login. It doesn't bring the system down.

shutdown is an alias to systemctl command and is available in the system only for compatibility reasons.

How to Use shutdown

When used without any argument, shutdown command will simply power off the machine.

sudo shutdown

How to shut down the system at a specific time

To schedule the shutdown at a specific time, you can follow two different formats. It can be an absolute time in the hh:mm format and relative time in the +m format, where m is the number of minutes from now.

If you want to schedule a system shutdown at 7:00 AM, run the following command:

sudo shutdown 07:00

How to shut down the system immediately

To shut down the system immediately, use +0 or its alias now:

sudo shutdown now

How to broadcast a custom message

If you want to broadcast a custom message with the standard shutdown notification, run the following command:

sudo shutdown +20 "Software update"

In the above example, the system will shut down in 20 minutes from now and users will get a message that the software will update.

It is important to specify a time argument when specifying a custom message.

How to reboot the system

1) Use the -r argument to reboot the system:

sudo shutdown -r

2) It is also possible to specify a time argument and a custom message:

shutdown -r +15 "Updating software"

The above command will reboot the system after 15 minutes and broadcast the updating software message.

How to cancel a scheduled shutdown

In case you want to cancel the scheduled shutdown, execute the following command:

sudo shutdown -c

It won't be possible to schedule the cancellation as you can't specify the time argument, but you can still broadcast a message to all the users.

sudo shutdown -c "Canceling the reboot"

FAQs to Use Linux Shutdown Command

How do I use the shutdown command? 

Open the terminal, type "shutdown" followed by the desired options and parameters, such as shutdown time or reboot flag, and press Enter.

Can I schedule a shutdown with the Linux shutdown command? 

Yes, by specifying a shutdown time or delay, you can schedule a future shutdown. For example, "shutdown -h 20:00" will schedule a shutdown for 8:00 PM.

What is the difference between shutdown and reboot commands? 

The shutdown command shuts down the system, while the reboot command restarts it. Both commands can be used with options to define specific behaviors.

How can I cancel a scheduled shutdown using the shutdown command? 

You can cancel a scheduled shutdown by using the "shutdown -c" command, which aborts the shutdown operation.

What are some common options supported by the shutdown command? 

Common options include "-h" for immediate shutdown, "-r" for immediate reboot, "-k" for notifying users before shutdown, and "-c" to cancel a scheduled shutdown.

Can the shutdown command be used with a message to notify users? 

Yes, you can include a custom message using the "-k" option, which sends a warning message to all logged-in users before initiating the shutdown.

Does the shutdown command require root or superuser privileges? 

In most cases, the shutdown command requires root or superuser privileges to prevent unauthorized shutdowns and ensure system stability.

Conclusion

Using the shutdown command, you can halt, power off, and reboot your Linux system.

We hope this detailed guide helped you understand, how to use the shutdown command.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them for sure.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.