How to log out with a command in a gnome-less environment?

33,047

Solution 1

You could restart the desktop manager, which is similar to restarting X.

On Ubuntu 11.10:

sudo service lightdm restart

On earlier versions:

sudo service gdm restart

If that fails or you are on a very old system, try:

sudo /etc/init.d/gdm restart

One of these should take you back to the login screen. Be aware that you will not be prompted, so save any work before running this command!

Solution 2

<modkey> + shift + q is the default command for killing the wm client on dwm and awesome. This effectively returns to the logout screen. Tested on a MacBook Air XUbuntu 12.10 with dmw, where it is alt + shift + q.Tested on a ThinkPad running Debian Stretch with awesome 3.5.

Solution 3

On Ubuntu 12.04 you can use

/usr/lib/indicator-session/gtk-logout-helper --logout

It opens a dialog box. I use it with Awesome Window Manager.

To directly logout, you can also (softly) kill your window manager.

Solution 4

Have you tried

/usr/bin/gnome-session-quit  --logout --no-prompt

This works for me in an Awesome WM Gnome session. Since GNOME 3.10 or so the --logout --no-prompt is now needed because I guess the dialog box is gone.

Share:
33,047

Related videos on Youtube

Aleksandar Belic
Author by

Aleksandar Belic

Updated on September 18, 2022

Comments

  • Aleksandar Belic
    Aleksandar Belic over 1 year

    I installed various window managers (Awesome, dwm, etc.) from which I am not able to log out back to the login screen (gnome-session) in order to switch to another window manager. I need to reboot to do that, which is a waste of time (and can lead to data corruption).

    Question How can you log out via the terminal? didn't work..

    dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.Logout uint32:1
    

    ..neither did this:

    gnome-session-save --force-logout
    

    ..nor that:

    gnome-session-quit --force-logout
    

    they all returned:

    Failed to call logout: The name org.gnome.SessionManager was not provided by any .service files
    

    Is there a quick way to log out back into Gnome's session manager from a non-Gnome desktop manager using a terminal emulator? I know that CTRL+ALT+BACKSPACE can be configured to restart X, but I'm looking for the easiest way to log out.

    • Admin
      Admin about 12 years
      Could you not just log out by just quitting the WM - i.e Mod4+Shift+Q for awesome?
  • cadrian
    cadrian over 10 years
    This kills all connected users. Not always what you want.
  • ignis
    ignis over 10 years
    To switch users leaving the session open, one can use dm-tool switch-to-greeter or Ctrl + Alt + F{7,8}. Tested on Xubuntu 13.04 + i3.
  • gertvdijk
    gertvdijk over 9 years
    That'll send the regular SIGTERM signal to all processes at the same time rather than a graceful termination of the desktop environment as it should. This is different in terms of applications asking you to save your work or not. In a case of unsaved work this results in possible loss of that data compared to regular log out. So, -1.
  • Silvio Bandeira
    Silvio Bandeira over 9 years
    Read what the person asking the question is trying to accomplish before giving your opinion: " (...) I need to reboot to do that, which is a waste of time". If he needs to reboot, the efect on unsaved work is EXACTLY the same.
  • Silvio Bandeira
    Silvio Bandeira over 9 years
    Still, killall command works and is very useful when you don't have other ways like when the interface freezes.
  • Fabby
    Fabby over 9 years
    Silvio, yes, you're right, but the user you're answering may not know the impact of what he's doing and the next newbie on the block looking for an easy answer will definitely not know that. So if you rephrase your answer with the potential disadvantages and that [Ctrl][Alt][Backspace] is a better solution but that your solution is better then a reboot, I'm pretty sure Gert and me will upvote your answer instead of downvoting it. ;-)
  • Kaz Wolfe
    Kaz Wolfe over 9 years
    Note to Flaggers: Do not mark technically incorrect and/or "bad" answers as "low quality". The downvote button is there for a reason.
  • Tim Bray
    Tim Bray almost 6 years
    This just kills everything. Dangerous. Do not run this unless you are sure.