How to Shutdown a Linux Machine Using Terminal

Suraj Joshi Feb 02, 2024
  1. Syntax of shutdown Command in Linux
  2. Shutdown the System Using shutdown
  3. Shutdown the System After the Specified Time With the shudown Command
  4. Broadcast Message to All the Users Before the Shutdown
  5. Reboot the System With the shudown Command
  6. Cancel a Scheduled Shutdown With the shudown Command
How to Shutdown a Linux Machine Using Terminal

We use the shutdown command in Linux to shut down the Linux machine using the terminal. The command shuts down the system in a secure way by notifying all the logged in users and processes. We also have the option of shutting down after a certain time interval using the shutdown command.

Syntax of shutdown Command in Linux

shutdown [OPTIONS] [TIME] [MESSAGE]

Here, OPTIONS represents various shutdown options like power off(default option), halt, or reboot, TIME specifies the time after which the system is to be shut down, and MESSAGE represents the message that needs to be broadcasted to all the users.

Only users with sudo privileges can execute the shutdown command.

Shutdown the System Using shutdown

sudo shutdown

It shuts down the system after 1 minute, which is the default time of shutdown.

Shutdown the System After the Specified Time With the shudown Command

sudo shutdown 13:50

It shuts down the system exactly at 13:50 or 1:50 P.M

We can also specify minutes for shutdown using +m format, where m denotes the minutes to wait before shutdown.

sudo shutdown +20

It shuts down the system exactly after 20 minutes of execution of the command.

To shut down the system instantly, we use +0 or now in the time field.

sudo shutdown now

It shuts down the system instantly.

Broadcast Message to All the Users Before the Shutdown

To broadcast a particular message to all the users, we specify the message in the message field after the time field.

sudo shutdown +20 "System Maintenance"

It shuts down the system exactly after 20 minutes of execution of the command and notifies all the users with the message System Maintenance.

Reboot the System With the shudown Command

We use the -r option with the shutdown command to reboot the system.

sudo shutdown -r +20 

It reboots the system after 20 minutes from the time of execution of the above command.

Cancel a Scheduled Shutdown With the shudown Command

To Cancel a Scheduled Shutdown, we use the -c option with the shutdown command.

sudo shutdown -c "Postpone Shutdown for tomorrow"

It cancels the scheduled shutdown broadcasting the message Postpone Shutdown for tomorrow to all the users. We cannot specify time while canceling the scheduled shutdown.

Author: Suraj Joshi
Suraj Joshi avatar Suraj Joshi avatar

Suraj Joshi is a backend software engineer at Matrice.ai.

LinkedIn