2

Raspberry Pi 1 Model A running Raspbian Stretch Lite here. What's the preferred method for elegantly shutting down the pi (so that all services shut down correctly & safely, etc.)?

Looks like I have several options:

sudo shutdown -h now
sudo shutdown -P now
sudo poweroff
sudo halt -p
sudo init 0

Or I could just unplug the power and let it crash (I don't like this method).

Ideally my teardown procedure would be something like:

  1. When I'm ready to shut it down, SSH into the RPi
  2. Issue some command (see above -- any ideas?) to shut it down
  3. Wait for all the onboard lights to turn off
  4. Unplug the power (Micro USB) safely

Just wondering if there is a preferred/best practices way to go about this.

3

Something worth noting from the manual page for halt, poweroff and reboot is:

These are legacy commands available for compatibility only.

At the bottom is a "see also" for systemctl, and man systemctl has further details regarding the difference between the three things (in context, systemctl halt, systemctl reboot, etc). As Milliways points out in a comment below, the three legacy commands are actually symbolic links to systemctl.1

My own preference is halt since it's the shortest to type; on machines that can be powered off I use halt -p. However, this does not apply to the pi.

init 0

This is an anachronism that, again, will work for backward compatibility. However, if you are new to linux you should avoid it since the init system, systemd, does not use SysV runlevels (so don't bother thinking in those terms).

I could just unplug the power and let it crash

Please see "Is it okay to just pull the plug?".


1. They are still treated differently because the executable can check what name it was invoked with.

  • 1
    The man page does state that, and ALL are symlinks to /bin/systemctl (as are many other commands) BUT (at least on the Pi) they are NOT identical. I use poweroff because it provides a visual indication when shutdown is complete - raspberrypi.stackexchange.com/a/42188/8697 – Milliways Sep 15 '17 at 23:51
  • @Milliways If you mean the ACT 2 Hz blink followed by one long blink, I get identical behaviour for shutdown now, poweroff, and halt. – goldilocks Sep 16 '17 at 12:35
  • poweroff gives 10 binks at 1 second intervals. (At least it did on Jessie; I rarely power my Pi off and haven't checked recently.) I normally use heartbeat so the difference is obvious. – Milliways Sep 16 '17 at 22:45

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.