To shutdown:

sudo shutdown -h now

To restart

sudo shutdown -r now

By master