Raspberry Pi Linux LESSON 10: Properly and Safely Shutting Down the Raspberry Pi

It is very easy to corrupt the SD card and your operating system on your Raspberry Pi. It is important to always properly shut down the raspberry pi. Never just remove power, always shutdown first. Never remove the SD card while the pi is booted or while it is powered. To remove the SD card, first shutdown the pi, then take the power off, then remove the card. Similarly, never plug the card in while the pi is powered.

The simplest way to shutdown the pi is with the command:

$ sudo halt

Instead, if you want to shutdown and then reboot, you can use:

$ sudo reboot

These two commands will take care of things most of the time. If for some reason sudo halt does not work, you can try the following:

$ sudo shutdown -h now

That will pretty much always work.