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?
3 Answers
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.

- 2,740
- 4
- 23
- 36
The documentation is in man shutdown
.1
-P, --poweroff
Power-off the machine (the default).
[...]
-h
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.

- 58,859
- 17
- 112
- 227
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

- 2,740
- 4
- 23
- 36

- 111
- 2
halt
it could cause data loss. A much better practice would besudo 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:38halt
from runlevel 0 or 6, it could cause data loss. At any other runlevel, it's equivalent toshutdown -h now
. – Mark Jul 28 '15 at 02:29init 0
to shutdown,init 6
to restart – rkosegi Jul 28 '15 at 09:37shutdown -h now
, didn't realisehalt
was dangerous! – otah007 Aug 13 '15 at 18:28