Logout from Different Desktop Environments from Command Line


Some people spend all day in terminals, even though there’s a desktop environment running. I normally have four different terminals open on my main screen, in a normal quadrant pattern. I arrange them on the taskbar so they are clockwise, starting in the upper left quadrant.


Suppose you want to close your session, without having to use the mouse or pressing the Super key or anything like that.

You want to enter a command from your terminal that will close your session. Here is a list of how to do that, for each different desktop environment (DE) I’ve collected so far.

Logout from desktop environments

Logout from cinnamon from command line

cinnamon-session-quit --logout --force

Logout from xfce from command line

xfce-session-quit -l

Logout from GNOME Shell from command line


Logout from KDE4 from command line

qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1

Logout from KDE5 from command line

With confirmation

qdbus org.kde.ksmserver /KSMServer logout 1 3 3

Without confirmation

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

Logout from desktop environment from command line

loginctl terminate-user username



  1. Cinnamon https://forums.linuxmint.com/viewtopic.php?t=177547
  2. Gnome https://askubuntu.com/questions/15795/how-can-you-log-out-via-the-terminal#15796
  3. KDE4 http://www.techlw.com/2012/07/log-out-in-ubuntu-from-command-line.html
  4. KDE5 Plasma https://forum.kde.org/viewtopic.php?f=289&t=135065
  5. Extra reading for KDE https://majewsky.wordpress.com/2009/07/11/shutdown-your-machine-automatically-or-from-remote/