In this guide, I will take you through all the steps on how to shutdown a Raspberry Pi correctly.
As you may have already noticed, there is no button to switch the Raspberry Pi on or off. Your first instinct is probably to pull the power cord, but this is highly not recommended.
There are many reasons why pulling the power cord while your operating system is still running is not a good idea.
Firstly, by pulling the power cord out early, you heighten the risk of your SD card becoming corrupt.
Secondly, anything that is running will not make a graceful exit and save. This forced exit may cause data loss depending on what your Raspberry Pi was doing at the time.
There are more issues that can arise from removing the power cord without first shutting down the operating system, but I am sure you get the point. Incorrectly shutting down the Pi can cause issues.
Luckily shutting down the Raspberry Pi is extremely easy, just see below for all the steps on how to do it correctly.
The Shutdown Command
The easiest way to shutdown the Raspberry Pi correctly is to use a very simple command. You can find the command right below.
sudo shutdown -h now
It will do the following process to ensure the operating system shutdowns gracefully.
1. It will send SIGTERM to all the running processes, so they can save and exit gracefully.
2. After an interval, it sends SIGKILL, so that any remaining processes will be halted.
3. Lastly, it will unmount all the file systems.
4. The screen will now show System Halted.
5. You can now remove the power cord with minimal risk to your Raspberry Pi and the operating system.
6. To start the Raspberry Pi simply plug back in the USB power cord.
There are further ways you can improve on this such as building your own power button by making use of the GPIO pins. I will go into how to do this in the near future.
I hope that this very short but important guide has shown you how to shutdown a Raspberry Pi correctly. If you have any feedback on this tutorial, then be sure to join us over at our forum.