For shutdown:
sudo poweroff
For restart:
sudo reboot
The best answer form ask ubuntu https://askubuntu.com/questions/187071/how-do-i-shut-down-or-reboot-from-a-terminal