Do you want to shutdown or reboot Ubuntu Linux from a terminal or a shell prompt? If GUI is working you can always click on a Quit button. If GUI is not working or if you are working remotely over ssh type the following command:
Shutdown Ubuntu Linux From Terminal
Type the command:
sudo halt
or
sudo shutdown -h now
Reboot Ubuntu Linux From Terminal
Type the command:
sudo reboot
If you want more options on these two commands then type the following commands (man page):
man shutdown
man reboot