Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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

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?

share|improve this question
Maybe the name of the DE matters, who knows. – Tshepang Mar 16 '11 at 7:23
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
@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.

share|improve this answer

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.

share|improve this answer
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

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

Use killall -u $USER for logout.

share|improve this answer
Why the downvote without comment? It logs the user out from any DE, just as requested – roaima Nov 5 '15 at 19:50
@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 at 4:22

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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