How to log out current user?
If you are using gnome,
gnome-session-quit
or
gnome-session-save --force-logout
or also
dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1
If you use KDE,
qdbus org.kde.ksmserver /KSMServer org.kde.KSMServerInterface.logout -1 -1 -1
In LXDE,
lxde-logout
In XFCE,
xfce4-session-logout
Whatever your desktop environment, you can define an alias to make your life easier. Edit the file /home/your_name/.bashrc,
and place in it, toward the end, the following line:
alias mylg='gnome-session-quit'
or whichever command you wish. Source the file,
source .bashrc
and you now have a brand new command, mylg, which will log you out.
Related videos on Youtube
cdonts
Updated on September 18, 2022Comments
-
cdonts over 1 year
I'm very very new to the linux world. I have just installed Ubuntu 12.04 and I was wondering how to log out my user using the terminal. I searched the web and all the sites say that I should run the command
logout
orexit
. But here's the problem. Usinglogout
throws me a message saying I should useexit
. And usingexit
just closes the terminal, I'm still logged in.How can achieve this?
Thanks in advance.
-
Rudu over 10 years
exit
should be the correct term, when you say "log out" do you mean leave the XWindow (GUI) system? -
cdonts over 10 yearsHi thanks for your answer. Yes, I mean that or going back where you need to put your user password to log in (just like a log out in Windows).
-
MariusMatutiae over 10 yearsIn the upper right hand corner there are several small icons. Click on one them at a time, one will present you with the options Shutdown/Logout/restart computer.
-
cdonts over 10 yearsThanks for your answer but I'm asking about doing that from the terminal/command line.
-
-
cdonts over 10 yearsThe first command works on Ubuntu. Thanks a lot!