Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have googled for a while, but I still haven't found a clear answer to the differences between halt and poweroff options for shutdown. So I would like to ask this question here.

If it helps, my computer is Lenovo T400 and OS is Ubuntu 12.04

Note: I am talking about two options to the command shutdown. Is command halt the same as shutdown -H, and command poweroff the same as shutdown -P?

Thanks!

share|improve this question
    
Related: unix.stackexchange.com/questions/8690/… –  slm Nov 16 '13 at 8:10

2 Answers 2

up vote 14 down vote accepted

It's a bit historical.

halt was used before ACPI (which today will turn off the power for you)*. It would halt the system and then print a message to the effect of "it's ok to power off now". Back then there were physical on/off switches, rather than the combo ACPI controlled power button of modern computers.

poweroff, naturally will halt the system and then call ACPI power off.

* These days halt is smart enough to automatically call poweroff if ACPI is enabled. In fact, they are functionally equivalent now.

share|improve this answer
    
Interesting: on my laptop that runs Gentoo, /sbin/poweroff is a symlink to /sbin/halt. –  phunehehe Jul 8 '12 at 8:10
    
Thanks, bahamat! I am talking about two options to the command shutdown. Is command halt the same as shutdown -H, and command poweroff the same as shutdown -P? @phunehehe too. –  Tim Jul 8 '12 at 12:17
    
@phunehehe: Yeah, I was pretty sure they're the same now, but didn't bother to look. –  bahamat Jul 8 '12 at 17:56
    
@Tim: Yes, those flags are the same as calling the command. Like I said, it's pretty much a historical difference. –  bahamat Jul 8 '12 at 17:56
1  
Back in the day, halt used to do just that. No orderly shutdown, just stop what the machine was doing right then and there. It was common to issue sync;sync;sync;halt to make sure all buffers had been written out to disk. –  kurtm Oct 27 '13 at 2:19

They're not the same thing, just very closely related. In practice, unless you want to specify a particular time to shutdown or to force an immediate unclean reboot/halt/poweroff, it really doesn't matter whether you run shutdown -h or halt... or shutdown -r vs reboot. Things weren't so nicely convenient in the past, but this is the way it works now (a lot of the opportunities for ambiguity or user error have been removed/smoothed out).

/sbin/shutdown does a lot of "cleanup" stuff like notifying users, blocking new logins while the system is shutting down. It can also be told to shutdown the system at a certain time or in XX minutes - warning logged-in users every so often of the impending shutdown.

It also changes runlevel to 0 (halt/poweroff) or 6 (reboot) which triggers the system to stop the running services, unmount disks, etc in preparation for the actual halt, poweroff, or reboot.

When all that is done, it then calls /sbin/halt, /sbin/reboot, or /sbin/poweroff (reboot and poweroff are usually symlinks to halt, which interprets them as halt -r and halt -P respectively).

Note, however, that if halt/reboot/poweroff is called when the system is NOT in runlevel 0 or 6 then they will call shutdown to do its job unless the -f or force option is used.

(The details of how run-levels are interpreted may vary from distro to distro, but 0 and 6 are used as described here in Debian and Debian-derivatives like Ubuntu).

See the man pages for shutdown and halt for more info.

Finally, the distinction between halt and poweroff state is that halt does everything up to actually powering the machine off (on some kinds of hardware this means it drops into a ROM bootloader or similar. On most PC hardware it just halts), while poweroff completes that final step and switches off. reboot, of course, gets to the halt state and then reboots the computer.

BTW, the default is typically to either poweroff or reboot, but you can use -H as an argument to shutdown to make it halt instead. This isn't very useful on PC-based linux boxes (but is useful on machines, like sparc boxes, that have a firmware boot monitor. It's possible it may become useful on newer machines with an EFI command line).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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