shutdown Command in Linux with Examples

This tutorial explains Linux “shutdown” command, options and its usage with examples.

shutdown – brings the system down. You can shutdown the machine immediately, or schedule a shutdown using 24 hour format.

Description:

shutdown brings the system down in a secure way. All logged-in users are notified that the system is going down.

It is possible to shut the system down immediately or after a specified delay. All processes are first notified that the system is going down by the signal SIGTERM.

This gives programs like vi the time to save the file being edited, mail and news processing programs a chance to exit cleanly, etc. shutdown does its job by signalling the init process, asking it to change the runlevel.

advertisement
advertisement

Runlevel 0 is used to halt the system, runlevel 6 is used to reboot the system, and runlevel 1 is used to put to system into a state where administrative tasks can be performed; this is the default if neither the -h or -r flag is given to shutdown.

Synopsis :
shutdown [OPTION]… TIME [MESSAGE]

TIME may have different formats, the most common is simply the word ‘now’ which will bring the system down immediately. Other valid formats are +m, where m is the number of minutes to wait until shutting down and hh:mm which specifies the time on the 24hr clock.

OPTIONS:

-r
Requests that the system be rebooted after it has been brought down.
-h
Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system.
-H
Requests that the system be halted after it has been brought down.
-P
Requests that the system be powered off after it has been brought down.
-c
Cancels a running shutdown. TIME is not specified with this option, the first argument is MESSAGE.
-k
Only send out the warning messages and disable logins, do not actually bring the system down.
-f
Skip fsck on reboot.
-F
Force fsck on reboot.

Examples :

1. Halting with a custom message

advertisement
$ shutdown -h now 'System is going down now'
 
Broadcast message from @
	(/dev/pts/1) at 1:36 ...
 
The system is going down for halt NOW!
System is going down now

2. Scheduling a reboot :

$ shutdown -r 20:00
 
Broadcast message from @
	(/dev/pts/1) at 10:27 ...
 
The system is going down for reboot in 573 minutes!

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

advertisement
If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.