I'm new to Linux (using Raspbian) and Raspberry Pi, and I'm wondering which of the two commands mentioned in the title that I should use when powering off my Pi. I googled them but still don't really get the difference between the two, does it matter which one I use?


Try typing man shutdown. The man pages give you a complete list of the options that a command can take, and an explanation of what they do. In the case of -h:

-h Requests that the system be either halted or powered off after it has been brought down, with the choice as to which left up to the system.

The difference between including the -h option or not, is slight, and is irrelevant in this case, as you can't poweroff the Pi anyway, not without manually removing the USB power.

| improve this answer | |

The documentation is in man shutdown.1

-P, --poweroff
           Power-off the machine (the default).


           Equivalent to --poweroff, unless --halt is specified.

Sometimes commands have redundant seeming switches like this because they must satisfy specifications for several different contexts. Simple logic tells us that since poweroff is the default anyway, using -h is itself redundant (again, it exists to satisfy an external spec; some implementations of shutdown may not work this way by default, but all the ones that conform will implement -h).

Since the pi itself can't poweroff (it is either plugged in == on, or not), there is no point in using poweroff, but it won't cause any harm. It may make a difference WRT the way the red LED blinks at the end (you could compare with shutdown -H to see). Note the major purpose of shutdown is to stop (halt) the OS from running.

So you can use either form.

1. This one is actually from Raspbian jessie and comes with systemd; it is slightly different from the shutdown in Raspbian wheezy (Greenonline's answer quotes that), which is an example of what I mention in the next paragraph about different implementations meeting the same specification. The shutdown process is actually part of the init system, which is SysV on wheezy and systemd on jessie.

| improve this answer | |

I prefer

sudo halt

I can't remember why I chose this, but, for whatever reason, other commands cause problems. This works perfectly. To reboot:

sudo restart
| improve this answer | |
  • 2
    If you perform just a halt it could cause data loss. A much better practice would be sudo sync;sync;halt, as this synchronises the data storage (i.e hard disks, SD card), with any unwritten cached data still in memory, before halting the system. – Greenonline Jul 27 '15 at 18:38
  • 2
    @Greenonline, if you perform a halt from runlevel 0 or 6, it could cause data loss. At any other runlevel, it's equivalent to shutdown -h now. – Mark Jul 28 '15 at 2:29
  • 1
    Why does users tends to ignore existence of "init" command on unix-like OSes? init 0 to shutdown, init 6 to restart – rkosegi Jul 28 '15 at 9:37
  • @Greenonline, @Mark, From now on I'll use shutdown -h now, didn't realise halt was dangerous! – otah007 Aug 13 '15 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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