Shut down computer from keyboard

In older versions of Ubuntu Ctrl + Alt + Del will bring up options for shutdown, restart, suspend and hibernate. These can then be selected with the arrow keys and Enter.

For a single hit solution in later versions you can use this script to create a keyboard shortcut. First you need to download the script and save it on your computer. Next you need to make it executable by right clicking on it and going to properties → Permissions → Allow executing file as a program. Finally go to System SettingsKeyboardShortcutsCustom Shortcuts and click the small plus symbol. For the command type in

/home/toby/power.sh shutdown

or whatever path you saved the script to.

Suspend, hibernate and restart are also available by this method; just replace shutdown in the above command.


There are some low level keyboard shortcuts available. They talk directly to the kernel and can break things. You probably shouldn't use these. But in the interest of counter-acting the atrocious answers recommending this method, here's how to use the SysReq button to shutdown or reboot your system. If your cpu bursts into flames because of these incantations, well, can't say I didn't warn you.

Graceful

Reboot

There is a mnemonic here: busier backwards. As in, you are too busy to shutdown properly, so you are doing it backwards.

alt + SysRq + r , e , i , s , u , b

I borrowed this from wikipedia*:

unRaw      (take control of keyboard back from X),
 tErminate (send SIGTERM to all processes, allowing them to terminate gracefully),
 kIll      (send SIGKILL to all processes, forcing them to terminate immediately),
  Sync     (flush data to disk),
  Unmount  (remount all filesystems read-only),
reBoot     (durr)

Shutdown

This is the same except at the end use o for Off instead of b for reBoot.

alt + SysRq + r , e , i , s , u , o

Destructive

This is like yanking the power cord out. You risk destroying recently saved data (files not quite actually written to disk) and you will definitely lose anything unsaved. On the upside, it is quick and to the point.

reBoot: alt + SysRq + b

shut Off: alt + SysRq + o

Use in graphical desktop environment

Under graphical environments like Unity, alt + SysRq takes a screenshot. You must hold down ctrl as well.

Thank you wikipedia for the information in this post.


11.10 and later

Pressing Ctrl+Alt+Del leads to the logout dialog. If you need the old functionality back you will have to define your own shortcut by opening Keyboard -> Shortcuts from System settings and add this command:

gnome-session-quit --power-off

enter image description here

Alternatively we can use a shoutdown only dialog as shown in this answer

/usr/lib/indicator-session/gtk-logout-helper --shutdown

enter image description here

Note

Before we can use Ctrl+Alt+Del we will have to assign another shortcut to logout.


11.04 and earlier

Using default keyboard settings pressing Ctrl+Alt+Del will open the following window:

enter image description here

The first entry is selected by default for an immediate shutdown by just pressing Return in addition.

There also is a countdown that shuts down your system after 60s without any further keyboard action.


Well, an easy one to try is to open the keyboard shortcuts.

If using Unity, press the window key/superkey and then type shor and select keyboard shortcuts. Here you can then create a new shortcut and then assign a key combo to shut your pc down… without using your power button!

The command for your shortcut should be:

/usr/lib/indicator-session/gtk-logout-helper -s

Which will shut you down!!

Here is mine which I did to test it:

Shut down!