What is the best way to shutdown a Raspberry Pi?

Scenario:

You want to shut down your Raspberry Pi but you’re not sure the best way to do it.

Solution:

The number one thing is you should not just unplug the power cable. Uplugging the power source before properly shutting down the OS can cause file system corruption. From the command prompt enter one of these commands to shut down (then power off).

Preferred Command:
   sudo shutdown -h now
Alternate Commands:
   sudo halt
   sudo poweroff