Part of the beauty of trying out alpha releases of operating systems is that things will break, including things we take for granted. Today it's the turn of the logout button.

So, how do you log out from the desktop environment du jour from the command line?

  • Maybe the name of the DE matters, who knows. – Tshepang Mar 16 '11 at 7:23
  • 1
    It does matter. The version matters, too: in KDE 3 it involves dcop, in KDE 4 it's one of those long ugly dbus commands. – geekosaur Mar 16 '11 at 7:25
  • @tsephang Eh, those days I'm trying to test a number of Gnome based shells (Unity mainly, Unity 2D too), but I hoped to get a DE-agnostic answer if possible. – badp Mar 16 '11 at 7:33
  • 1
    @badp: check this out: stackapps.com/q/2051/5198 I say that cuz u got my name wrong. – Tshepang Mar 16 '11 at 7:36
  • @tshepang Whoops. – badp Mar 16 '11 at 7:50

/usr/bin/gnome-session-save --kill works for me on Fedora 15 Alpha with gnome as my DE. Hope that helps.


The X server will die if you kill the session's main process, and all other X clients will die when they lose the connection to the X server.

Under Gnome (at least under Ubuntu 10.04), the session's process is gnome-session. If you're not using a desktop environment, the process you want is the session manager, or if you're not running one, the window manager. More precisely, the process you need to kill is the first client that connected to the X server.

  • Thanks for this explanation!! I'm on a bare-bones Debian install, so there IS no gdm or kdm to kill. Your explanation for why one would want to kill the display manager in the first place led me to the answer I needed. Thanks, dude!! :D – kittykittybangbang Nov 23 '15 at 18:46

/etc/init.d/gdm restart


/etc/init.d/kdm restart


As long as you've got the "DontZap" set to "off" in your xorg.conf, you can use control-alt-backspace to kill your running X server. I've used this in situations when the X environment is so messed up I can't run a command. If everything is significantly wedged, you might benefit from using the Magic Sysrq keys 'k' to kill off all processes in the current VT, and if it's really wedged, you can reboot your system a bit more cleanly than a hard poweroff. Sadly, when testing the compositing WMs I did this more often than I'd like.


In Ubuntu 12.04 with default gnome it is gnome-session-quit.


Use killall -u $USER for logout.

  • Why the downvote without comment? It logs the user out from any DE, just as requested – roaima Nov 5 '15 at 19:50
  • 1
    @roaima Way late, but this can also kill other things that the user may not want to be killed, like screens or (maybe?) EMACS/URxvt daemons. – Elronnd May 3 '16 at 4:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.