In this article, we are going to learn the Linux shutdown command with examples. the shutdown command is used to Halt/Shutdown, Reboot the Linux Operating System.
Follow the below Linux shutdown command with Examples:
To Shutdown a Linux operating system use the shutdown command with argument -h. Here I am using the word ‘now‘ to Shutdown the System immediately.
Syntax : shutdown [Option] [Time]
[root@localhost ~]# shutdown -h now # Immediate Shutdown a Linux System
You can set a time in minutes after which the system will get Shutdown. For Example, if you want to Shutdown the system after 1 Minute then set the time as +1 with the shutdown command. Refer to the command below.
[root@localhost ~]# shutdown -h +1 # Shutdown the System after 1 Minute Broadcast message from root@localhost.localdomain (/dev/pts/1) at 20:19 ... The system is going down for halt in 1 minute!
If you want to send some message to the user before shutdown the system then you can do so by using the shutdown command. Refer to the command below. The message is Highlighted in Red Color.
[root@localhost ~]# shutdown -h +10 "System is going to Shutdown" # Send a Message to user before Shutdown the System Broadcast message from root@dhcpserver.itsmarttricks.com (/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 available by which you can Shutdown the system. For Example, the halt command can be used to shut down the system.
[root@localhost ~]# halt # Shutdown a Linux System
Also Read : Complete Unix Commands And Basic Linux Commands With Examples For Beginners
Also, you can use the power off command to shutdown the system.
[root@localhost ~]# poweroff # Shutdown the System [root@localhost ~]# poweroff -f # Shutdown the System Forcefully
To restart a Linux system use the shutdown command with argument -r. Here I am using the word ‘now‘ to Restart the system Immediately.
[root@localhost ~]# shutdown -r now # Restart a System Immediately
You can set a time in minutes after which the system will get Restart. Here I want to restart the system after 2 Minutes so set time as +2 with the shutdown command.
[root@localhost ~]# shutdown -r +2 # Restart the system after 2 Minutes Broadcast message from root@localhost.localdomain (/dev/pts/1) at 20:21 ... The system is going down for reboot in 2 minutes!
You can also use a reboot command to Restart the Linux Operating System.
[root@localhost ~]# reboot # Restart the System [root@localhost ~]# reboot -f # Restart the System Forcefully
If you want to send some message to the user before Reboot the system then you can do so by using the shutdown command. Refer to the command below.
[root@localhost ~]# shutdown -r +10 "System is going to Reboot" Broadcast message from root@dhcpserver.itsmarttricks.com (/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 a running shutdown.
[root@localhost ~]# shutdown -c # Cancel a Running Shutdown
shutdown command with argument -k will only send a fake shutdown warning to the user but will not shutdown.
[root@localhost ~]# shutdown -k +1 "System is going to Shutdown" # Send a fake Shutdown Warning Broadcast message from root@dhcpserver.itsmarttricks.com (/dev/pts/0) at 9:07 ... The system is going down for maintenance in 1 minute! System is going to Shutdown
To Power Off the Linux system just use a shutdown command with argument -P. Here I am going to Power Off the system after 1 Minute
[root@localhost ~]# shutdown -P +1 # Power Off the System after 1 Minute Broadcast message from root@dhcpserver.itsmarttricks.com (/dev/pts/0) at 9:10 ... The system is going down for power off in 1 minute!
Here you might be thinking that What is the difference between Halt and Power Off. The exact difference between Halt and Power Off is in Halt only the Operating System gets down but in the case of Power Off the Operating System gets down and then the system instructs the ACPI to send a signal to Power Unit to Power Off the System. ACPI stands for Advanced Configuration Power Interface.
For more help on the Linux shutdown, you can use the below command.
[root@localhost ~]# 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 have explained Best Shutdown Command With Examples. I hope you enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment.