Shutdown command is used to bring the system down in a safe and secure way. When the shutdown process is initiated, all the logged in users are notified that the system is going down right now or after some time. Using this command you can set specific time to make down your system.
In this context, we shall look into how to Use Shutdown Command on Ubuntu 20.04.
Shutdown Command Syntax
Before going to ahead to learn how to use shutdown command, you should know the basic syntax.
Below is the basic syntax for the shutdown utility:
$ shutdown [OPTIONS] [TIME] [MESSAGE]
- options – You can use Shutdown options like halt, power off or reboot the system.
- time – It specifies that when shutdown process should perform.
- message – Set the message which you want to show to all users before start shutdown process.
How to use Shutdown Command ?
If you will issue shutdown command without any option then it will considered default(power off) option and power off the machine.
$ sudo shutdown
Once you will execute above command system will shutdown within 1 minute which is default time interval. You will see output as below:
Shutdown scheduled for Wed 2021-05-02 17:24:27 EDT, use 'shutdown -c' to cancel.
How to Shutdown System Immediately ?
By default, shutdown interval time is 1 minute but you can skip that delay and shutdown immediately using now as time argument. To do so use below command:
$ sudo shutdown now
It will immediately shutdown your system without any message or notification.
How to Shutdown System At Specified Time ?
Time argument is used to shutdown system at specific time. You can specify time argument in two different format: hh:mm for relative and +m for number of minutes. By using these formats you can schedule a shutdown at specific time.
Below command will schedule shutdown at 04:00 AM :
$ sudo shutdown 04:00
Following will schedule shutdown after 15 minutes from now:
$ sudo shutdown +15
How to Broadcast a Custom Message ?
Using message argument you can broadcast a custom message to all the users when performing the shutdown process. It important to specify time argument when broadcasting a message.
Here, system shutdown in 15 minutes from now and notify users that maintenance will perform.
$ sudo shutdown +15 "Maintenance"
How to Cancel the Shutdown ?
If you have already scheduled shutdown and want to cancel then you can do it using the -c argument. It will cancel shutdown process immediately.
Run the below command to cancel scheduled shutdown:
$ sudo shutdown -c
At the time of cancellation you can not specify time argument but you can broadcast a custom message. Execute below command:
$ sudo shutdown -c "Canceled shutdown"
How to Reboot System ?
Using -r argument you can reboot the system. Run the below command:
$ sudo shutdown -r
Also, you can specify time and custom message as below:
$ shutdown -r +5 "Update System"