What is the difference between the halt
and shutdown
commands?
command-line – Difference Between Halt and Shutdown Commands
command lineshutdown
Related Question
- Centos – the difference between the whatis and apropos commands
- Bash – the difference between “eval” and “source /dev/stdin”
- Linux Shutdown – Difference Between Commands for Bringing Down a Server
- command-line – Difference Between find . and find . -print
- Shell – the difference between * and *.* while copying
Best Answer
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):
Or to reboot it with a custom, 30 minute advance warning:
After the delay,
shutdown
tellsinit
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
orreboot
command, which syncs changes to disks and then performs the actual halt/power off or reboot.On Linux, if
halt
orreboot
is run when the system has not already started the shutdown process, it will invoke theshutdown
command automatically rather than directly performing its intended action. However, on systems such as FreeBSD, these commands first log the action inwtmp
and then will immediately perform the halt/reboot themselves, without first killing processes or unmounting filesystems.