3

I would like to create a two hotkeys. First for terminating all procesess and shutdown the system and turn computer off.

I have tried something but it only logged me off and then I had to confirm I want to log off and then turn off computer manually.

The second one for simple log off.

What is the command I should type in keyboard/hotkey settings? Or should I make .sh file and run it? What command for running the file should I use then?

Thank you very much!

0

2 Answers 2

9

gksudo shutdown -h now would come to mind, but this command requires root privileges. To execute it you would have to enter you password.

Here's a command that should work without root and shut down your PC immediately (compatible with all official Ubuntu flavors):

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

These are Xubuntu-specific:

  • shutdown: xfce4-session-logout --halt
  • restart: xfce4-session-logout --reboot
  • log out: xfce4-session-logout --logout
  • suspend: xfce4-session-logout --suspend
  • hibernate: xfce4-session-logout --hibernate

Sources:

http://bbs.archbang.org/viewtopic.php?pid=9078#p9078

http://linux.die.net/man/1/xfce4-session-logout

3
  • 1
    Did you want --halt (instead of --logout) for the shutdown command?
    – kiri
    Sep 1, 2013 at 8:30
  • 1
    And it's --reboot not restart.
    – Daniel
    Jun 2, 2015 at 16:35
  • 1
    Also interesting option might be --fast option to shutdown fast without saving the session.
    – Sebastian
    Dec 4, 2017 at 20:35
0

You should have a look at the 'Magic SysRq key' which is enabled by default on Linux

Press Alt+SysRq+E to close all processes

To cleanly reboot:

Used in sequence, some of these actions can be used to cleanly end processes, flush data to disk, unmount all file systems, and restart your computer. To perform this process, press and hold the Alt + SysRq key combination and – while holding the Alt and SysRq keys down — type the following keys in order, pausing for several seconds in between each key:

reisub

To shutdown instead, press o instead of b at the end of the above sequence.

(source)

4
  • 1
    The Magic SysRq key combo is an emergency shutdown procedure. I would advise against using it if you don't have to. Sep 1, 2013 at 8:05
  • @Glutanimate It may be worse than clicking 'shutdown' from the menu but it's better than just doing a hardware shutdown. It asks processes to close nicely and writes data to disk before actually powering off. See the link 'Magic SysRq Key' in my answer for info about what each key does
    – kiri
    Sep 1, 2013 at 8:07
  • 1
    Yes, but it still bypasses the natural shutdown procedure and should be reserved for emergency cases only. There are less radical alternatives out there. Sep 1, 2013 at 8:19
  • OK, agreed with that.
    – kiri
    Sep 1, 2013 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .