Unix & Linux: What is the difference between Halt and Shutdown commands? (5 Solutions!!)
Channel: Roel Van de Paar
Date: 10/08/2020

Unix & Linux: What is the difference between Halt and Shutdown commands?


The Question: What is the difference between the halt and shutdown commands?

Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful

== This solution helped 11 people ==
I suspect this is somewhat dependant on which version of UNIX/Linux you are
using. On Centos (and I expec other modern Linux) halt calls shutdown
(providing you're not at http://en.wikipedia.org/wiki/Runlevel 0 or 6) so your
system will be shutdown cleanly. On Solaris 10 halt is more brutal, it just
flushes the disk caches and powers off the system - no attempt is made to run
any scripts or shutdown smf facilities.

In linux, "halt" and "reboot" are aliases of the shutdown command -- shutdown -
h and shutdown -r respectively. Bareword shutdown generally assumes -h.

== This solution helped 81 people ==
Generally, one uses the shutdown_command. It allows a time delay and warning
message before shutdown or reboot, which is important for system administration
of multiuser shell servers; it can provide the users with advance notice of the
downtime.
As such, the shutdown command has to be used like this to halt/switch off the
computer immediately (on Linux and FreeBSD at least):
shutdown -h now
Or to reboot it with a custom, 30 minute advance warning:
shutdown -r +30 "Planned software upgrades"
After the delay, shutdown tells init to change to runlevel 0 (halt) or 6
(reboot). (Note that omitting -h or -r will cause the system to go into single-
user mode (runlevel 1), which kills most system processes but does not actually
halt the system; it still allows the administrator to remain logged in as
root.)
Once system processes have been killed and filesystems have been unmounted, the
system halts/powers off or reboots automatically. This is done using the halt
or_reboot_command, which syncs changes to disks and then performs the actual
halt/power off or reboot.
On Linux, if halt or reboot is run when the system has not already started the
shutdown process, it will invoke the shutdown command automatically rather than
directly performing its intended action. However, http://www.gsp.com/cgi-bin/
man.cgi?section=8&topic=halt, these commands first log the action in wtmp and
then will immediately perform the halt/reboot themselves, without first killing
processes or unmounting filesystems.

With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music: https://www.bensound.com/royalty-free-music | Images: https://stocksnap.io/license & others | With thanks to user wassimans (https://unix.stackexchange.com/users/2897), user Stephane Rolland (https://unix.stackexchange.com/users/4175), user Shadur (https://unix.stackexchange.com/users/4949), user PleaseStand (https://unix.stackexchange.com/users/5426), user K7AAY (https://unix.stackexchange.com/users/49368), user JdeBP (https://unix.stackexchange.com/users/5132), user dveim (https://unix.stackexchange.com/users/306456), and the Stack Exchange Network (http://unix.stackexchange.com/questions/8690). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.