Updated May 16, 2023
Definition of Linux Shutdown Command
The shutdown command in Linux helps in shutting down the system in a secure way. When the root user initiates the shutdown command, the system notifies all logged-in users that the system will shut down. In this article, we will show how to use the shutdown command in Linux and to manage this command with different options. We have briefly explained the options with snippets for better understanding.
Syntax of Linux Shutdown Command
shutdown [options] [time] [message]
Here,
- Options: The system can be shut down using a few choices, such as halt, reboot, or power down.
- Time: Time specifies at what time the shutdown should process.
- Message: The message option specifies what letter will be broadcast to all users when shutdown is initiated.
sudo shutdown
Examples of Linux Shutdown Command
Here are a few illustrations of how the shutdown command functions in Linux, along with screenshots.
How to Shutdown the System at a Specified Time?
There are two different ways to handle time arguments. One way is to specify the absolute time in hh:mm format, and another way is to mention +m where ‘m’ is the minutes from now.
Example:
Here this example means the system will be shutdown at 5 AM.
sudo shutdown 05:00
The example below means the machine will be shutdown 20 minutes from now.
sudo shutdown +20
How to Shutdown the Machine Immediately?
There are two different ways to handle time arguments. One way is to specify the alias as now, and another way is to mention +0 where ‘0’ is the minutes from now.
Example:
sudo shutdown now
sudo shutdown +0
How to Send Custom Message While Shutdown?
The following syntax is to shut down the system 20 minutes from now and send the message “System Shutdown in 20 minutes” to all logged-in users.
Example:
sudo shutdown +20 "System Shutdown in 20 minutes"
We must note that when specifying a custom message to notify the users, we must include the time argument along with the message.
How to Halt the Machine?
We can use option -H to halt the system. Halting the system means halting all CPUs and powering off the system. Additionally, we must make sure the system and main power are turned off.
Syntax:
sudo shutdown -H
How to Shutdown and Power Off the System?
By default, this is possible manually, but we can also do this by using option -P to shut down the system and to power off it explicitly.
Syntax:
sudo shutdown -P
How to Reboot the Machine?
There are two different ways to handle reboot arguments. One way is to use option -r, and another way is to mention the time arguments with a customized message.
Example:
sudo shutdown -r
sudo shutdown -r +10 "Rebooting the system in 10 minutes"
How to Cancel a Specified Shutdown?
Using option -c, we can modify the time that a shutdown is scheduled for if one is planned.
When we cancel the shutdown, we cannot mention time parameters, but we can send customized messages to all the logged-in users. The syntax for this is given below.
Syntax:
sudo shutdown -c
Before the shutdown is canceled, in this case, the notification is distributed to all users. Note that time arguments are not specified.
sudo shutdown -c "Cancelling the shutdown now"
Conclusion
Administrators generally use this command to manage the system. The shutdown command in Linux helps in shutting down the system in a secure way. Once we issue the shutdown command, the system prevents all currently logged-in users from logging in and notifies them that a shutdown is impending. The shutdown might happen right away or it could be planned to last for 24 hours. It’s crucial to remember that only root users can shut down a system.
Recommended Articles
We hope that this EDUCBA information on “Linux Shutdown Command” was beneficial to you. You can view EDUCBA’s recommended articles for more information.