Definition of Linux Shutdown Command
The shutdown command in Linux helps in shutting down the system in a secure way. When we initiate the shutdown command, all the users who are logged in and also processes are therefore notified that there will be shutdown in the system and thus no further logins are allowed in the system. We can shutdown the system immediately or in a schedule by 24-hour format. It is to be noted that only root users have the permissions to shutdown the system.
In this article, we will show how to use 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: There are few options like halt, reboot, or power off options that are used to shutdown the system.
- Time: Time specifies at what time the shutdown should process.
- Message: The message option specifies what message is to be broadcast to all users when shutdown is initiated.
How does Shutdown Command Work in Linux?
There are few options used in shutdown command to manage the system. Below are the options and their descriptions.
- -r: It will allow to request that the system be rebooted once the system is been brought down.
- -h: It will allow to request the machine to either halt or power off once it is brought down, it is then left to the choice of the system.
- -H: It will allow to request that the machine be halted once it is been brought down.
- -P: It will allow requesting that the machine to be powered off once it is brought down.
- -c: It will cancel the running shutdown. With this option, the TIME parameter is not mentioned with this option and the first parameter is the message option.
- -k: It will only be used in sending out the warning messages and to disable the logins, it will not allow the machine down.
Shutdown Command in Linux:
Only root users has the permissions to shutdown the system. Basic format to shutdown the system is given below:
sudo shutdown
Examples of Linux Shutdown Command
Below are few examples listed with screenshots to show how shutdown command works in Linux.
How to Shutdown the System at 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
Here the below example 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 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?
Below is the syntax given for shutting down the system in 20 minutes from now and then the logged in users will receive the message “System Shutdown in 20 minutes”
Example:
sudo shutdown +20 "System Shutdown in 20 minutes"
It is to be noted that when we specify a custom message to notify the users, we must also mention 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 to halt all CPUs and to power off the system. We also need to make sure that the system and main power is disconnected.
Syntax for halting the system is given below.
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 shutdown the system and to power off it explicitly. Syntax of this is given below.
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 with the time arguments with a customized message. This is shown below.
Example:
sudo shutdown -r
sudo shutdown -r +10 "Rebooting the system in 10 minutes"
How to Cancel a Specified Shutdown?
Whenever if any shutdown is scheduled and we would want to cancel that particular scheduled time, we can do it by using option -c.
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
Here the message is sent out to all the users before canceling the shutdown. Note that time arguments are not specified.
sudo shutdown -c "Cancelling the shutdown now"
Conclusion
The shutdown command is one of the useful commands sued in Linux OS. This command is generally used by administrators to manage the system. The shutdown command in Linux helps in shutting down the system in a secure way. When we initiate the shutdown command, all the users who are logged in and also processes are therefore notified that there will be shutdown in the system and thus no further logins are allowed in the system. We can shutdown the system immediately or in a schedule by 24-hour format. It is to be noted that only root users have the permissions to shutdown the system.
Recommended Articles
This is a guide to Linux Shutdown Command. Here we also discuss the definition and how does shutdown command work in Linux along with different examples. You may also have a look at the following articles to learn more –
16 Online Courses | 3 Hands-on Projects | 160+ Hours | Verifiable Certificate of Completion
4.5
View Course
Related Courses