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
Below is the
shutdown command syntax in Linux:
shutdown [OPTIONS] [TIME] [MESSAGE]
- 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
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
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 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:00
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:00
Let’s now schedule a system shutdown for 30 minutes from now:
sudo shutdown +30
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."
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
-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:00
To schedule a system restart 30 minutes from now:
sudo shutdown -r +30
Canceling the Shutdown
The scheduled shutdown can be canceled anytime using the
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
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`
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:
I agree, it’s probably not the most elegant solution, but it does the job.
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.