3

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.

Ghanima
  • 15,958
  • 17
  • 65
  • 125
smeeb
  • 645
  • 3
  • 9
  • 22

1 Answers1

4

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.

goldilocks
  • 60,325
  • 17
  • 117
  • 234