Xubuntu hotkey for immediate shutdown

7,938

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

Share:
7,938

Related videos on Youtube

Sebastian
Author by

Sebastian

The founder and designer of www.nottelo.com, searching for right people to work with. Especially Javascript / Typescript / Angular 2 / Java developers are welcomed. Let me know via e-mail form on nottelo.com/joinus!

Updated on September 18, 2022

Comments

  • Sebastian
    Sebastian over 1 year

    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!

  • kiri
    kiri over 10 years
    @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
  • Glutanimate
    Glutanimate over 10 years
    Yes, but it still bypasses the natural shutdown procedure and should be reserved for emergency cases only. There are less radical alternatives out there.
  • kiri
    kiri over 10 years
    OK, agreed with that.
  • kiri
    kiri over 10 years
    Did you want --halt (instead of --logout) for the shutdown command?
  • Daniel
    Daniel almost 9 years
    And it's --reboot not restart.
  • Sebastian
    Sebastian over 6 years
    Also interesting option might be --fast option to shutdown fast without saving the session.