What is the difference between Halt and Shutdown commands?

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, on systems such as FreeBSD, these commands first log the action in wtmp and then will immediately perform the halt/reboot themselves, without first killing processes or unmounting filesystems.


The past

In the 1980s, the BSDs had halt, reboot, and shutdown. System 5 UNIX had a BSD compatibility toolset. But natively it had its own, different, shutdown command; and didn't have halt or reboot at all. (Some System 5 variants had things like SCO XENIX's haltsys.)

The BSD halt and reboot commands were low-level, drastic, and immediate. The considerate way to shut down a BSD system was the shutdown command, which did all of the things that one expects to happen: wall messages to users, services gracefully killed, log entries written, logins disabled, and so forth.

Whilst the BSDs were largely where the received wisdom originated that "shutdown execs halt/reboot", and that the latter were to be used with care; it was the System 5 world where people learned the contrary habit that halt/reboot were just handy shorthands and nothing more: /usr/ucb/halt, from the "BSD Compatibility Package", was no different in effect to shutdown -h. They both ended up doing init 0.

Further reading

  • halt. 1982-05-11. 4.2BSD manual.
  • haltsys. 2005-06-03. SCO OpenServer manual.
  • AT&T (1990). UNIX System 5 Release 4: BSD/XENIX Compatibility Guide. Prentice Hall.
  • AT&T (1990). UNIX System 5 Release 4: System Admninistrators' Guide. Prentice Hall.

Today

Nowadays, we have a range of possible system management toolsets. The BSDs still have their toolset, albeit purged of any possible AT&Tisms in the 1990s. Miquel van Smoorenburg in 1992 (re-)wrote a Linux init+rc, and their associated tools, which people now refer to as "System 5 init", even though it isn't actually the software from UNIX System 5 (and isn't just init). There are also systemd, upstart, and nosh, each of which have their own implementations of halt, reboot, fasthalt, fastboot, and so forth.

The toolsets have also grown and changed. There's now a poweroff command, not present in 1980s operating systems because the Central Processing Units on most contemporary machines had no way of controlling their power supplies. Linux toolsets in particular have aquired the BSD commands; but like the BSD compatibility tools on UNIX System 5, they aren't exact workalikes and things have been largely flattened.

This flattening has brought us to the point where halt and shutdown are mostly the same. But the exact details vary from toolset to toolset, and the mechanics of each toolset are all slightly different.

It has also brought us to the slightly embarrassing position where this command set has become so festooned with compatibility options that it now allows people to give computers self-contradictory instructions like reboot --halt and poweroff --reboot, as I noted in the manual page for the nosh halt, fasthalt, reboot, fastboot, and poweroff commands. ☺

The systemd toolset

halt, reboot, poweroff, telinit, and shutdown are all one program. It's actually systemd's own systemctl program. It has several command line parsers for the various command line syntaxes of those commands, as well as its own, but after that largely funnels into one code path internally. There's no difference between using halt and its command options to trigger an action and using shutdown and its command options to trigger the same action.

systemd does not consider rescue mode (which is what the systemd people have renamed single user mode) to be a shut down system state, and it is not reachable with any of these commands. Option-less shutdown now is the same as poweroff.

Further reading:

  • https://unix.stackexchange.com/a/196014/5132 .

The BSDs

The BSDs largely retain their 1980s semantics. halt and shutdown are thus very much not equivalent in their toolsets. halt and reboot are one single program; and are still low level, immediate, and drastic. Whereas shutdown and poweroff, also one single program, do all of the considerate things like scheduled shutdown, writing wall messages, logging actions, disabling login, and so forth.

In the BSD toolsets, shutdown/poweroff traditionally ended up invoking halt/reboot to enact the final system state change. The (often nowadays incorrect) received wisdom that "shutdown execs halt/reboot" in fact still holds on NetBSD and OpenBSD. But on FreeBSD/TrueOS/DragonFlyBSD it is only the case if the -o option is used. On these BSDs, both of these programs normally enact the final system state change by sending various signals (INT, USR1, and USR2) to process #1. init does all system state management on on these systems.

On all of them, option-less shutdown now is not equivalent to any of halt, reboot, or poweroff. It transitions to the BSD single user mode, from which one can transition back to multi-user mode.

Further reading:

  • shutdown. System Manager's Manual. NetBSD Manual pages. 2011-11-04.
  • reboot, halt. OpenBSD Manual pages. 2016-09-03.
  • shutdown. FreeBSD Manual pages. 2016-09-21.
  • reboot, halt, fastboot, fasthalt. FreeBSD Manual pages. 2017-03-19.
  • shutdown. System Manager's Manual. DragonFlyBSD Manual pages. 2016-09-29.
  • reboot, halt, fastboot, fasthalt. System Manager's Manual. DragonFlyBSD Manual pages. 2016-09-29.

The nosh toolset

In the nosh system management toolset, halt, fasthalt, poweroff, fastpoweroff, reboot, and fastboot are all one program. It's a backwards compatibility shim that normally simply chains to shutdown, the opposite of received wisdom. The --force option makes it chain to system-control instead.

So there's no difference (absent --force) between the halt command and the shutdown command (with the equivalent option) in this toolset, as this set of "BSD/System 5 compatibility" commands is simply a thin shim layer over the top of shutdown.

Further reading:

  • Jonathan de Boyne Pollard (2018). shutdown. nosh toolset manual pages. Softwares.
  • Jonathan de Boyne Pollard (2018). telinit, init, reboot, halt, haltsys, powercycle, poweroff, … fastboot, fasthalt, fastpowercycle, fastpoweroff, … nosh toolset manual pages. Softwares.

The upstart toolset

Like with nosh, in the upstart system management toolset the opposite of received BSD wisdom applies. halt, reboot, and poweroff are all one program, that normally chains to shutdown; unless the --force option is used, which makes it make the reboot() system call itself.

So, again, there's no difference (absent --force) between the halt command and and shutdown command (with the equivalent option) in this toolset. Also again, option-less shutdown now (which none of halt, reboot, or poweroff can end up invoking as they all set options) brings the system into single user mode rather than shutting it down.

Further reading:

  • Scott James Remnant. shutdown(8). Ubuntu manual pages.
  • Scott James Remnant. reboot(8), halt(8), poweroff(8). Ubuntu manual pages.

The Linux System 5 init+rc toolset

Again, in this toolset the opposite of received BSD wisdom applies and halt and reboot simply chain to shutdown — unless the system is already in the poweroff or halt "run-levels", in which case these commands actually enact the final system state change. shutdown in its turn chains to init.

So, again, there's no difference (unless the system is already largely shut down) between halt and shutdown because the former just invokes the latter. And yes, again, option-less shutdown now (which none of halt, reboot, or poweroff can end up invoking as they all set options) brings the system into single user mode rather than shutting it down.


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 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.