1

Is there a way to log out & log back in as another user or the same user, all from the command line? I have seen solutions that use killall or pkill, etc., to kill all processes running as the logged-in user.

This certainly works, and logs me out, but when I log back in I find that all of my processes have been killed, as I totally did not expect after running that command. All my terminals are closed, as well as my browser, etc. It is as if my desktop were started fresh from being powered off.

On the other hand, when I "lock" the computer by using the context menu on the top-right corner of the screen, and then log back in, everything I had open is still open, and all of my processes have not been killed. In this context menu, "logging out" means "killing all processes and starting fresh", which is what I do not want, and "locking" is "logging out but not stopping all processes so that when you log back in everything is still open", which is what I want.

How do I lock the computer, without fully logging out, directly from the command line? Or at least, how does the context menu at the top right corner of the screen do it? What command(s) does it run internally, and how can I emulate that without confirmation?

I am on Ubuntu 15.04 x64 with hardware from System76, if this helps at all.

trysis
  • 111
  • 1
  • 4

1 Answers1

1

As you might be aware, you can look up via the terminal using

gnome-session-quit

(see How can you log out via the terminal?)

You can perhaps try something like

gnome-session-quit && startx 

However, I don't think that the startx command would actually execute here. Obviously you could login from the login screen, but this probably isn't quite what you're looking for.

nathanesau
  • 127
  • 4