How to properly shutdown or reboot a Unix/Linux server

What is the correct way to turn off a Unix/Linux server?

From my googling, I have learned (hopefully) the following:

shutdown: I should use this, with the parameter -h to halt, or the parameter -r to reboot

halt: halts the computer (stops the processor? does this physically turn the power of the computer off?). I think this will call shutdown if not at init0, otherwise just halts.

reboot: if not at init6, calls shutdown, otherwise just reboots the computer.

if all that is correct, then the only thing I can't figure out is what exactly 'halt' does. Does it just stop the processor but not turn the computer physically off? How do I "poweroff" the computer?

Thanks


shutdown -h now will shut off the computer with most systems, but it is left up to the implementation. Use -P to poweroff for sure and -H to halt for sure. This is the method I would recommend to shut the system down. It will run all the proper scripts.

halt without -f will just call the above shutdown and so will reboot, they are basically just aliases.


On Linux, I have always used reboot and halt, though I also know people who find halt scary. halt(8) sort of tells why:

Under older sysvinit releases, reboot and halt should never be called directly. From release 2.74 on halt and reboot invoke shutdown(8) if the system is not in runlevel 0 or 6. This means that if halt or reboot cannot find out the current runlevel (for example, when /var/run/utmp hasn't been initialized correctly) shutdown will be called, which might not be what you want. Use the -f flag if you want to do a hard halt or reboot.

sysvinit 2.74 is dated 17-Mar-1998 21:53. :)

Regarding your question how to power off, you could use poweroff or halt -p. Most recent Linux systems seem to power down on just halt or shutdown -h also.


I use halt - less parameters to remember.

Someone have developed a virtual Molly Guard to ensure one does not stop the wrong server by accident. It has saved me on a few occasions. It's packagned in molly-guard on Ubuntu.


I generally use (as the root user of course):

 init 0

to bring the system to a power off state. This performs rundown scripting.

 init 6

to bring down the system and to have it automagically reboot. This also performs rundown scripting.