Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?


share|improve this question
up vote 10 down vote accepted

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.

share|improve this answer
I am a big fan of /sbin/shutdown -h(-r) now. using "halt" always scared me. – RateControl Aug 3 '09 at 16:07
Thoreau makes another good point: you should try to make a habit of calling important system commands with an explicit path, ( e.g. /sbin/shutdown ). This might save you if your system is ever compromised and you are not aware of it. – Ryan Fisher Aug 3 '09 at 17:40
mystikphish: Agreed, going to adopt that habit. Although he has a good point, I don't know if I would trust his advice on IT in general if he spends all his time in a one room cabin with no electricity. – Kyle Brandt Aug 3 '09 at 18:37
It would be a poor compromise if it didn't change the executable in the path that is engrained in your fingers though... – asjo Aug 3 '09 at 20:48
@Kyle Brandt, nice. – Joseph Kern Aug 4 '09 at 11:23

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.

share|improve this answer
Solaris is still in the crowd where 'halt' does scary things. – Karl Katzke Aug 4 '09 at 19:43

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.

share|improve this answer
In case anyone else wonders how molly-guard works, here's an example:… – Marie Fischer Aug 3 '09 at 19:21

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.

share|improve this answer
halt would also run all initscripts with "stop" parameter. – hayalci Aug 3 '09 at 20:32
On what system does halt not shut down nicely? – asjo Aug 3 '09 at 20:48
Based on the above two comments I edited my note to remove my halt comment. However, I verified on FreeBSD 7.2, and Solaris 10 5/2009 x86 executing the simple halt command on these two systems will NOT engage standard rundown sequence. However, on Centos 5.3, OpenSUSe 11.1, and Fedora 11 the halt command DOES engage the standard rundown sequence and acts basically like init 0. FYI.... – mdpc Aug 4 '09 at 5:42

Worth noting here:

Solaris needs either "shutdown -y -i5 -g0" to shut down, or "shutdown -y -i6 -g0" to reboot. Halt or Reboot on Solaris should only be used when it's acceptable to not give a warning or grace period before you start shutting things down... this can kind of play havoc with disk systems if you don't unmount them before shutting off, y'know?

It's best to adopt procedures that are best for the operating systems you touch daily, so that you don't accidentally screw something badly at 2am with your fingers on autopilot.

For instance, never type 'killall' in solaris, whereas that's a fairly common command in linux. 'pkill' works the same on both, though.

share|improve this answer

To shut it down immediately ,type:

shutdown -h now 

and to shut it down immediately and restart type:

shutdown -r now
share|improve this answer
This doesn't contribute anything new to the 6 year old answers. – Sven Jun 27 '15 at 8:14

protected by Sven Jun 27 '15 at 8:13

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.