Using shutdown command the Linux system will be down in a secure way. When the shutdown command fired all the logged-in users will be notified that the system is going down, and no further logins are allowed. You can shutdown your system immediately or at the specified time. This article explains the shutdown command with examples.
Shutdown Command Syntax
Below is the basic syntax of shutdown command:
shutdown [OPTIONS] [TIME] [MESSAGE]
- options – Can pass the Shutdown options like power-off, reboot or halt the system.
- time – You can shutdown at specific time.
- message – The message argument specifies a message which will be broadcast to all users.
On the recent Linux distributions
shutdown is an alias to
systemctl and it is available in the system only for compatibility reasons.
Use the shutdown Command
To perform the shutdown command on Linux, you should logged in as root or user with sudo privileges.
When shutdown command passed without any argument, by default it will power-off the machine.
By default, the shutdown process will start after 1 minute.
Shutdown the System at a Specified Time
You also can set specific time for shutdown the system. You can pass the time argument using two different formats. 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.
Below command will schedule system shutdown at 9 A.M:
sudo shutdown 09:00
The following example will schedule system shutdown in 25 minutes from now:
sudo shutdown +25
To shut down your system immediately you can use
+0 or its alias now:
sudo shutdown now
Display a Custom Message
To broadcast a custom message along with the standard shutdown notification type your message after the time argument.
In below example the system will shut down 10 minutes from now and notify all logged-in users that a hardware upgrade will be performed:
sudo shutdown +10 "Hardware upgrade"
It is important to mention that when specifying a custom wall message, you must specify a time argument too.
Reboot the System
-r option along with shutdown command to reboot the system.
sudo shutdown -r
Specify a time argument and a custom message to display custom message and schedule on a time:
shutdown -r +5 "Software update"
Cancel a Scheduled Shutdown
You also can
cancel the scheduled shutdown using below command:
sudo shutdown -c
To specify the custom message why the scheduled shutdown has been canceled by typing:
sudo shutdown -c "Shutdown cancel"
To learn more about shutdown, visit the shutdown man page.
If you have any questions or suggestion , feel free to leave a comment below.