Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am accessing the machine (OpenSuse 11 with KDE) over NX.

I cannot use the Alt-Ctrl-Del shortcuts as it is captured by my system. The regular logoff button just ends the NX session without ending the KDE session. I cant call kdm restart as I have no root privileges.

Other wild guesses like logout and exit do not work either, the first one complaining about not being in a login shell and the second one just closing the console.

My shell-fu is weak, so any help is appreciated.

share|improve this question
@MartinSchröder - ah, good catch - it's essentially the same question. But Paul's answer to this question is more exhaustive that Gilles' answer to the other one. – kostja Feb 7 '15 at 16:37
up vote 10 down vote accepted

You can send a logout command via dbus to KDE, which should (if it can) terminate the session.

qdbus org.kde.ksmserver /KSMServer logout 0 0 0

dbus is a messaging system that lets applications communicate with each other, and the qdbus command is a utility for sending dbus messages to applications.

Applications register with dbus, and the ksmserver part of KDE is the session manager - it looks after who is logged in.

So we are sending a message to ksmserver to the /KSMServer interface and telling it to logout. The message we are sending is the exact same message that is sent to KSM when you click on the logout icon on your desktop.

The three zeros are parameters and can alter the type of logout we are doing:

First parameter:

  • 0 = Do not wait for confirmation
  • 1 = Wait for confirmation (with a 30 second timeout)

Second parameter:

  • -1 = Prompt for action, defaulting to shutdown (Only makes sense when waiting for confirmation.)
  • 0 = Logout
  • 1 = Restart
  • 2 = Shutdown

The third parameter is the "when" parameter, but it isn't clear what its impact is.

share|improve this answer
Can you please explain how and why that works? – Kevin Panko Dec 10 '13 at 18:39
@KevinPanko Sure - done. – Paul Dec 10 '13 at 22:31
Make sure to set the DISPLAY environment variable (most likely to :0) before you run this command, otherwise it will complain. – palswim Nov 30 '14 at 2:18

Have found this post containing multiple ways to achieve log out from shell. Using skill -KILL -u 'whoami' works nicely

share|improve this answer
"These tools are obsolete and unportable. The command syntax is poorly defined. Consider using the killall, pkill, and pgrep commands instead." Also this is not gracefull. – Martin Schröder Feb 7 '15 at 14:03

You must log in to answer this question.

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