AMP AMP

Shutdown Command in Linux with Examples

shutdown Command

Shutdown command is used to shutdown, restart or reboot the system. This command is used in both local machines and remote machines. And this command needs the root privilege.

Syntax

shutdown < option> < duration> < Task>

Shutting down the system

Now we can see how to shut down in a simple way without using any options.

[root@localhost]# shutdown -h now 

-h option is meant for halt which means to stop recursively.

[root@localhost]# shutdown -h +10    
" Server is going down 10 minutes from now. Please save your work." 

This means that shutdown will be done only after 10 mins.

[root@localhost]# shutdown -r  +5    
" Server will restart in 5 minutes from now. Please save your work." 

This means that system will restart in the given time.

To cancel the shutdown

[root@localhost]# shutdown -c 

Power off

The other way to shut down the system is using power off command.

[root@localhost]# poweroff 

On running this command it will shut down the system without doing any initial steps (i.e.,) prior precautions, it will pause turn off the system.

Restart command

In every system, if shutdown option is available then there will be restart option for sure.

[root@localhost]# restart 
The another option for shutdown is

[root@localhost]# init 6 

Reboot command

Reboot is as same as restart command.

[root@localhost]# reboot 

To reboot the machine forcefully

[root@localhost]# reboot -f 
-f for forcefully.

Halt command

This command is considered to be the dangerous one. Because while running this command it won’ t ask for any confirmations, it just pause every tasks running in both front and back.

[root@localhost]# halt 


The another option for shutdown is

[root@localhost]#  init 0 
FAQ
Q
How to set bring down the system immediately, and automatically reboot it in Linux?
A
You can use the option of "-P" with shutdown command to set bring down the system immediately, and automatically reboot it in Linux. For Ex: "shutdown -P now".
Q
How to set specify the time in hours and minutes to shutdown your system?
A
You will also specify the time in hours and minutes to shutdown your system. For ex: sudo shutdown 22:00
Q
How to set message which will appear on all users screens letting them know that a shutdown is going to occur?
A
If you are running a system with multiple users you can specify a message which will appear on all users screens letting them know that a shutdown is going to occur. Syntax: sudo shutdown 5
Q
What are all the commands in RHEL/CentOS/Red Hat server poweroff the system?
A
You can use any one of the following command and the basic syntax is: shutdown -h now OR shutdown -h 0 OR poweroff OR halt OR telinit 0
Q
What the procedure and command to shut down a Red Hat (RHEL)/CentOS Linux system?
A
Open the Terminal or login to the remote server over the ssh. Type the following command as root user to shutdown server immediately without any warning to the users: "# shutdown -h now" How