If you’re using Ubuntu or perhaps another flavour of Linux, there come a time when you need to either reboot (restart) or shutdown a machine via a terminal (command line) or shell command.
Of course, it does come as no surprise that in order to carry out either of these two commands, you will need administrator privileges on the machine that you are currently using, in other words, sudo is once more you best friend.
To shut down / power off your Ubuntu PC, type in the command:
sudo halt
or
sudo shutdown -h now
Alternatively, to restart / reboot your machine, enter the command:
sudo reboot
As always, more information on both of these commands can be found via the man system:
man reboot
man shutdown