Shut down or Reboot from terminal

For Ubuntu 14.10 or earlier:

Shutdown:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Stop 

Restart:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.ConsoleKit" /org/freedesktop/ConsoleKit/Manager org.freedesktop.ConsoleKit.Manager.Restart 

Other commands you may like:

Suspend:

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Suspend 

Hibernate: (if enabled on your system)

/usr/bin/dbus-send --system --print-reply --dest="org.freedesktop.UPower" /org/freedesktop/UPower org.freedesktop.UPower.Hibernate 

Open your terminal with CTRL+ALT+T and do these following commands

To shutdown the system:

sudo shutdown -h now  

To restart:

sudo reboot 

& one more command for restart:

sudo shutdown -r now 

Another way as one of the user mentioned.

For shutdown:

sudo halt 

or:

sudo init 0  

For restart:

sudo init 6 

For Ubuntu 15.04 and later:

(This is due to Ubuntu's shift in using systemd instead of Upstart)

systemctl poweroff  systemctl reboot  systemctl suspend  systemctl hibernate  systemctl hybrid-sleep 

Since hibernate is normally disabled by default in Ubuntu systems, you can enable this by checking this answer: http://askubuntu.com/a/617254/101985