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