This recipe shows how the Raspberry Pi can be powered off safely.
Before powering off the Raspberry Pi, it is important to first shut down the operating system so that all of the applications and services on the Raspberry Pi have a chance to complete any disk writing that may be in progress and to prepare for the next boot.
External devices, such as hard disks, also need time to shut down and flush their buffers. The shutdown
command also gives the devices attached to the Raspberry Pi an opportunity to clean up and prepare for the next boot.
After completing this recipe, you will be able to power off the Raspberry Pi safely.
Here are my ingredients:
An Initial Setup for the Raspberry Pi (refer to the Preparing for initiating the boot recipe)
An SD card formatted with the official Raspbian Linux image
The Raspberry Pi should already be powered on and booted before implementing this recipe.
Perform the following steps to shut down the Raspberry Pi:
If you have not already done so, log in to the Raspberry Pi as the user
pi
(the default password israspberry
):Raspbian GNU/Linux 7raspberrypi tty1 Raspberrypi login: pi Password: Last Login: Sun Jun 21 19:45:35 UTC 2015 on tty1 Linux raspberrypi 3.18.11-v7+ #781SMP PREEEMPT Tue Apr 21 18:07:59 BST 2015armv7l The programs included with the Debian GNU/Linux system are free software;The exact distribution terms for each program are described in the individual files in /user/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. pi@raspberrypi ~ $
Shut down and halt (
-h
) the operating system. This command is privileged. Use thesudo
prefix to run the shutdown command as a privileged user, as follows:pi@raspberrypi ~ $ sudo shutdown –h now Broadcast message from root@raspberrypi (pts/0) (Sun Jun 21 19:53:03 2015): The system is going down for system halt NOW!
After the
shutdown
command is executed, the Raspberry Pi will begin its shutdown process, displaying messages from applications, devices, and services, as they clean up and prepare for the next boot.Once the operating system has shut down, the Raspberry Pi will halt, leaving only a single red LED lit on the Raspberry Pi (as long as the LEDs are flashing, the Raspberry Pi is still busy shutting down).
The power supply can now be unplugged from the Raspberry Pi.
If you have not already logged into the Raspberry Pi, you will need to log in to the Raspberry Pi before shutting it down.
The default user is pi
. You should have already changed the default user's password during the first boot (refer to the Booting Raspbian Linux for the first time recipe). In case you have not changed it, the default password is raspberry
.
After logging in, the shutdown
command is executed with the –h
option, which tells the Raspberry Pi to halt after the operating system is shut down.
The shutdown
command is privileged. Therefore, the sudo
command is used as a prefix to temporarily grant privileges. More information on Executing commands with privileges can be found in Chapter 2, Administration.
The shutdown
command can also be used to reboot the system. Just use the –r
reboot option instead of the –h
halt option.
Rebooting the system when you're logged in as the user pi
can be done with the help of the following command:
pi@raspberrypi ~ $ sudo shutdown –r now
Synonyms exist for the shutdown
command, which include poweroff
and reboot
.
To power off the system instead of using shutdown –h
, you can also use the following command:
pi@raspberrypi ~ $ sudo poweroff
Instead of shutdown –r
, you can also use the following command:
pi@raspberrypi ~ $ sudo reboot
More information about these commands can be found in their man pages.
halt, reboot, poweroff – stop the system (http://manpages.debian.net/cgi-bin/man.cgi?query=halt): There are alternatives to the
shutdown
command. The Debian man page for halt, poweroff, and reboot describes these commands in detail.shutdown – bring the system down (http://manpages.debian.net/cgi-bin/man.cgi?query=shutdown): The
shutdown
command can be used to halt (-h
) or reboot (-r
) the system. The Debian man page forshutdown
describes the command and all of its options in detail.