Home Raspberry Pi OS Shutdown, Restart, Raspberry Pi command line

Shutdown, Restart, Raspberry Pi command line

by Abraham
shutdown raspberry pi

Like any other computer and operating system, plugging off the plug to shutdown can have adverse consequences. Unlike most computers, the Raspberry Pi lacks a power button. Therefore, some users opt to take shortcuts by just plugging out the power plug. This is one of the causes of corrupt SD cards. To avoid corrupting filesystems, losing your data and operating system, follow this article to the end.

Pulling the plug has been a significant cause of corrupt file systems. This might seem like a shortcut to shut down the Pi but remember shortcuts are always dangerous on most occasions.

It is much safer to use the GUI (menu bar) to safely shutdown or restart your Raspberry Pi rather than pulling off the plug. We shall be showing the safe ways to shut down and restart the Raspberry Pi using command-lines. The terminal helps execute the commands. By default, the Raspberry Pi user has sudo privileges which are vital to execute the commands. Remember, the commands have to be run with superuser privileges to avoid running into errors—enough of the theories. Let us get down to the process now.

Shutting Down the Raspberry Pi

To successfully shut down your Raspberry Pi, use the command below:

sudo halt

Alternative commands to shut down the Raspberry Pi are:

sudo poweroff
sudo shutdown -h now
sudo shutdown -h 10 # in 10 minutes
sudo init 0

If you are new to the commands, below is its breakdown to understand the commands and their functionalities quickly.

sudo – this command initiates superuser privileges
shutdown – this command shuts down the Raspberry Pi
-h – this command puts the Raspberry into a halt, meaning it cannot reboot.
-now - this command tells the user that the said command has to be initiated immediately (do this now)
- h 10 – this command tells the Raspberry Pi to shut down after 10 minutes.

We now hope that you understand what the commands do.

After the initiation of the shutdown process, the green LED will flash or rather blink several times. When it stops, then it is very safe to unplug the power cable. Please do not remove the power cable when the LED has not stopped blinking yet since it is dangerous to your Raspberry Pi.

A red LED is an indication that your Raspberry Pi is connected to a stable power supply and that you can power it on.

Restarting the Raspberry Pi

Use the command below to reboot your Raspberry Pi:

sudo reboot

Alternative commands to restart the Raspberry Pi are:

sudo shutdown -r now
sudo shutdown -r 10 # in 10 minutes
sudo init 6

Let’s breakdown the commands so that you get the concept behind the code functionality.

sudo – initiates superuser privileges
shutdown – this command shutdowns the Raspberry Pi
-r – this command reboots the Raspberry Pi after the shutdown command has been initialized.
- now – this command simply tells the user to execute the command immediately.
-r 10 - this command tells the Pi to restart after 10 minutes.
Init 6 – this command performs a quick reboot. It directly unmounts the file systems and performs a restart without necessarily killing any scripts.

Now we know the safe methods to shut down and restart our Raspberry Pi. Of course, some of you might find this to be kind of hectic, but the havoc you expose your computer to when you pull off the plug or switch off from the main switch cannot allow you to try such uncouth ways. You might end up incurring extra charges to buy a new SD card due to the risk you expose the SD card to when you opt for unsafe practices. At times you will lose your data due to these silly mistakes.

Therefore, it is avoidable, and you are no exception. Just try out the safe ways, and you will enjoy them much more.
You can also opt to purchase a power button to use in your Raspberry Pi. This is another safe method of shutting down and restarting the Pi. However, this topic shall not be covered in this article since our main aim is to learn how to shut down and restart the Raspberry Pi using the command line.

How the Command Lines work

This is a question that has been frequently asked. For instance, how is a safe shutdown more crucial, and how does it ensure your Raspberry Pi is safe? When shutting down or rebooting using the terminal’s commands, the Raspberry Pi first exits all running processes by sending the SIGTERM signal. This signal notifies the Pi process to save all their data gracefully before exiting. After the SIGTERM signal has been initiated, the Pi again sends another signal known as the SIGKILL signal.

The SIGKILL signal informs the remaining processes to stop, and then it unmounts all file systems. After unmounting the filesystems, it now tells the kernel to issue the standard ACPI command. The command will either restart or shut down the Pi, depending on the command executed in the terminal. Remember, this same process occurs whenever the GUI equivalents are used to either initiate a shutdown or a restart. I think you now have a clear view of what happens when safe methods are used.

On the other hand, when the ‘unsafe’ methods are used (pulling the plug off and switch off the main switch). The Pi is not given the room to save and exit the running process. This causes conflicts in the system, thus resulting in corrupt disks and file systems. Avoid these habits since they are dangerous to your Raspberry Pi, just as the saying shortcuts are always dangerous.


Don’t risk your Raspberry Pi by trying out unsafe methods that have been mentioned in the article. Always try out something new since it will help you learn and explore more. Therefore, we hope you will be able to shun away from unsafe habits and try out the safe practices of shutting down and restarting the Raspberry Pi’s covered in this article. Don’t allow the three seconds you use to pull the plug off or switch off the main switch to cost you extra bucks or your valuable data. Be safe and take care of your Raspberry Pi by using secure methods of shutting down and restarting.

You may also like

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.