shutdown vs halt

shutdown vs halt

Getting the difference between shutting a Unix system down versus halting it is kind of important.

Graceful shutdown

It’s important that your Unix/Linux system completes startup or shutdown in a graceful manner. What this means is that every process gets a chance to stop properly, rather than gets killed. It also means that these processes get stopped in a orderly manner – specifically following the order of appropriate startup/shutdown scripts or dependencies.

shutdown command does exactly that: it puts your desktop or server into a state of stopping services and preparing the server to be powered off.

Depending on your Unix/Linux implementation and command line options, a number of things will be requested by shutdown command before powering the system off:

  • warning about pending shutdown is broadcast to all the users logged into your system
  • a grace period (usually 1 minute) is started before shutdown proceeds
  • stop scripts are executed to correctly stop networked services
  • login attempts are blocked (new users won’t be able to log in)
  • processes are gracefully killed – meaning they can save data before shutting down

Relevant shutdown command options

If you want to immediately begin the shutdown procedure, you need to specify keyword now. If you want the server to power off and stay down, specify -h (for halt), if you want it to be rebooted, specify -r (for reboot).

IMPORTANT: If you don’t specify -h or -r, your Unix multiuser environment will be stopped and most OS services shut down, but the physical/virtual hardware will not be powered off. You’ll probably end up in a single user mode – where you can run admin commands as root.

Complete shutdown command for immediately bringing server down:

$ sudo shutdown -h now

Ungraceful shutdown: halt

halt command is another way to stop your Unix-like environment, but it’s more aggressive: no shutdown scripts or graceful process completion is allowed – it just stops Unix kernel.

halt also doesn’t really power your system off – it just stops your Unix/Linux environment from running. You still need to press the power button or activate the power switch.

See Also