BEST LINUX SHUTDOWN COMMAND WITH EXAMPLES
Introduction
In this article we are going to learn Linux shutdown command with examples. 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 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 time in minutes after which system will get Shutdown. For Example if you want to Shutdown the system after 1 Minute then set the time as +1 with shutdown command. Refer 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 user before shutdown the system then you can do so by using Linux shutdown command. Refer the command below. 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.elinuxbook.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 halt command can be used to shutdown the system.
[root@localhost ~]# halt # Shutdown a Linux System
Also Read :
- COMPLETE UNIX COMMANDS AND BASIC LINUX COMMANDS WITH EXAMPLES FOR BEGINNERS
- MOST USEFUL LINUX FREE COMMAND WITH EXAMPLES – A MEMORY USAGE MONITOR TOOL
Also you can use poweroff 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 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 time in minutes after which system will get Restart. Here I want to restart the system after 2 Minutes so set time as +2 with Linux 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 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 user before Reboot the system then you can do so by using Linux shutdown command. Refer the command below.
[root@localhost ~]# shutdown -r +10 "System is going to Reboot"
Broadcast message from root@dhcpserver.elinuxbook.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 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.elinuxbook.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 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.elinuxbook.com
(/dev/pts/0) at 9:10 ...
The system is going down for power off in 1 minute!
Here you might 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 case of Power Off the Operating System get down and then system instruct the ACPI to send signal to Power Unit to Power Off the System. ACPI stands for Advance Configuration Power Interface.
For more help on 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
If you found this article useful then Like Us, Share Us, Subscribe our Newsletter OR if you have something to say then feel free to comment on the comment box below.