Best Linux shutdown command with examples

In this article we will learn about the Linux shutdown command using examples. The shutdown command is used to pause / shutdown and restart the Linux operating system.

Best Linux shutdown command with examples

Follow the following Linux shutdown command with examples:

To shutdown a Linux operating system, use the shutdown command with an argument -H, Here I use the wordnowTo shut down the system immediately.

Syntax: shut down [Option] [Time]

[[email protected] ~]# shutdown -h now  # Immediate Shutdown a Linux System 

You can set the time in minutes after which the system shuts down. For example, if you want to shutdown the system after 1 minute, set the time +1 with the shutdown command. See the following command.

[[email protected] ~]# shutdown -h +1   # Shutdown the System after 1 Minute

Broadcast message from [email protected]
        (/dev/pts/1) at 20:19 ...

The system is going down for halt in 1 minute!

If you want to send a message to the user before shutting down the system, you can do so with the shutdown command. See the following command. The message is highlighted in red.

[[email protected] ~]# shutdown -h +10 "System is going to Shutdown"  # Send a Message to user before Shutdown the System

Broadcast message from [email protected]
        (/dev/pts/0) at 8:43 ...

The system is going down for halt in 10 minutes!
System is going to Shutdown

There are other commands you can use to shutdown the system. For example, Stop Command can be used to shutdown the system.

[[email protected] ~]# halt   # Shutdown a Linux System

Also Read: Complete Unix commands and basic Linux commands with examples for beginners

You can also use the poweroff command to shutdown the system.

[[email protected] ~]# poweroff  # Shutdown the System
  
[[email protected] ~]# poweroff -f   # Shutdown the System Forcefully

To restart a Linux system, use the shutdown command with the argument -r, Here I use the wordnowReboot the system immediately.

[[email protected] ~]# shutdown -r now   # Restart a System Immediately

You can set the time in minutes after which the system is restarted. Here I want to restart the system after 2 minutes, so set the time as +2 with the shutdown command.

[[email protected] ~]# shutdown -r +2   # Restart the system after 2 Minutes

Broadcast message from [email protected]
        (/dev/pts/1) at 20:21 ...

The system is going down for reboot in 2 minutes!

You can also use a restart command to restart the Linux operating system.

[[email protected] ~]# reboot   # Restart the System

[[email protected] ~]# reboot -f   # Restart the System Forcefully

If you want to send a message to the user before restarting the system, you can do so with the shutdown command. See the following command.

[[email protected] ~]# shutdown -r +10 "System is going to Reboot"

Broadcast message from [email protected]
        (/dev/pts/0) at 8:45 ...

The system is going down for reboot in 10 minutes!
System is going to Reboot

Shutdown command with argument -c can be used to cancel an ongoing shutdown.

[[email protected] ~]# shutdown -c  # Cancel a Running Shutdown

Shutdown command with argument -k only sends a fake shutdown warning to the user, but will not shutdown.

[[email protected] ~]# shutdown -k +1 "System is going to Shutdown"  # Send a fake Shutdown Warning
 
Broadcast message from [email protected]
        (/dev/pts/0) at 9:07 ...

The system is going down for maintenance in 1 minute!
System is going to Shutdown 

To shut down the Linux system, simply use the shutdown command with an argument -P, Here I will turn off the system after 1 minute

[[email protected] ~]# shutdown -P +1   # Power Off the System after 1 Minute

Broadcast message from [email protected]
        (/dev/pts/0) at 9:10 ...

The system is going down for power off in 1 minute!

Here you might be thinking what is the difference between Halt and Power Off. The exact difference between Halt and Power Off is in Stop only the operating system goes out of operation, but in the case of Turn off The operating system shuts down and the system instructs the ACPI to send a signal to the power supply to turn off the system. ACPI stands for Extended configuration power interface,

For more help shutting down Linux, you can use the following command.

[[email protected] ~]# shutdown --help   # For more Help on Shutdown Command
Usage: shutdown [OPTION]... TIME [MESSAGE]
Bring the system down.

Options:
  -r                          reboot after shutdown
  -h                          halt or power off after shutdown
  -H                          halt after shutdown (implies -h)
  -P                          power off after shutdown (implies -h)
  -c                          cancel a running shutdown
  -k                          only send warnings, don't shutdown
  -q, --quiet                 reduce output to errors only
  -v, --verbose               increase output to include informational messages
      --help                  display this help and exit
      --version               output version information and exit

Also Read: Top Basic Linux Commands for Beginners

That’s all. In this article we explained best shutdown command With examples. I hope you like this article. If you like this article, just share it. If you have any questions about this article, please comment.

Sidebar