How can you log out via the terminal?
Solution 1:
11.10 and above
gnome-session-quit
11.04 and previous versions
dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1
(via DoR, see his answer to "Reboot without sudoer privileges?" for more dbus goodness!)
or alternatively, you can use
gnome-session-save --force-logout
--force-logout
in contrast to just --logout
will not ask the user to deal with unsaved documents and so on.
is this the easiest way? no simple one line command like sudo logout?? I will never remember all that.
Yes, there is a command called logout, but it concerns the Terminal. gnome-session-save is the program that actually quits the gnome-session
, which you can of course kill, but that wouldn't qualify as logging out. :-)
Notice as well that these commands don't require you to be root.
You can always add an alias to your system if you want to have a shorter command.
Open ~/.bash_aliases
with a text editor, or create it if it isn't there, and add something like this to it:
alias logout-gnome="gnome-session-save --force-logout"
(.bashrc is a script that is run every time a new virtual terminal is started up, you should set up all your permanent aliases there, see also: How to create a permanent "alias"?)
Solution 2:
I had installed mate desktop and none of the menus worked, even the f-keys didn't work. I managed to get xterm through browsing with file manager.
The only thing that worked was :
sudo pkill -u username
Solution 3:
11.10 and above
Here's my personal solution!
In the terminal, run:
gedit ~/.bash_aliases
And add:
alias log-out="gnome-session-quit"
to the file! Now you just have to run log-out!