Ensuring that you shut down safely

To avoid any data corruption, you must ensure that you correctly shut down Raspberry Pi by issuing a shutdown command, as follows:

sudo shutdown -h now  

Or, use this one:

sudo halt  

You must wait until this command completes before you remove power from Raspberry Pi (wait for at least 10 seconds after the SD card access light has stopped flashing).

You can also restart the system with the reboot command, as follows:

sudo reboot  

Get Raspberry Pi 3 Cookbook for Python Programmers - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.