1

Is there any possibility to login as a different user while changing also the environment (or how do you say the wallpaper, shortcuts,...) via terminal command like su, ssh or login?

Like when you click switch user in the up right corner where your name is and then you log in to a different account.

By environment I mean the thing you see when you boot up the computer and normally login through the login screen. You have your wallpaper, toolbar etc.

So I just want to open terminal in my adam's environment and type login --change-enviroment john, rather than clicking adam in the up right corner, logging off and logging in like john

8
  • I am not sure if I follow your question correctly. Each and every user has their own environment set up.
    – Ramesh
    Jul 3, 2014 at 15:15
  • Yes, but su ssh or login won't change it, they change only the "beginning of the line" in terminal
    – Adam
    Jul 3, 2014 at 15:16
  • Are you referring to an X GUI login System?
    – ryekayo
    Jul 3, 2014 at 15:29
  • Hmm I want to switch user also graphically, not only in terminal
    – Adam
    Jul 3, 2014 at 15:32
  • But via a terminal command :D
    – Adam
    Jul 3, 2014 at 15:32

2 Answers 2

3

If you use lightdm display manager (man page), you can use dm-tool (man page) to switch to another user:

dm-tool switch-to-user USERNAME
0

You can run multiple X sessions on different VTs and toggle between them. VTs (virtual terminal) are the non-GUI consoles you can access via, e.g. Ctrl Alt F-#, where # is from 1-6. Your current X session already occupies one, so if F-1 doesn't work, try F-2, etc.

The console will have a login prompt (if you use a graphical login, that may be what you get instead -- I don't so I'm not sure). You can now login as whatever user you like. To start a new X session: startx.

You can now toggle between the two X sessions via the VTs they are running on. If it's not obvious, cycle through F 1-6 with ctrl-alt. You should be able to find both desktops.

5
  • interesting. But it says that startx command is not defined. Can this be controlled by a python script? Like subprocess.call("chvt 2") and then subprocess.call("credentials for the account"). Also, I need to log out the first user, so if I run pkill (can I when I do not know root password?) it will unfortunately log out the second user on VT, too, or not?
    – Adam
    Jul 3, 2014 at 18:09
  • Try xinit. If you want to actually switch users (log out and in again) but the normal method is too hard for you, your issue is a corner case -- i.e., you are looking for functionality few or no people could want, so no one has bothered to implement it. Either you hack your desktop, the login system, etc. and write the code yourself, or just deal with it.
    – goldilocks
    Jul 3, 2014 at 18:24
  • Ok, I thought that linux must have command for everything, so this basic action was implemented as a simple command. I googled, but I didn't find anything, so I posted it here.
    – Adam
    Jul 3, 2014 at 19:10
  • Part of the issue is the "switch user" widget is implemented as part of a particular desktop environment, of which there is a heterogeneous collection (GNOME, KDE, etc) or display manager (the GUI login) of which there is also a heterogeneous collection. The people who wrote the particular widget you are referring to probably could have written a command line version, but did not bother because they did not think it worth the effort. Since these things are open source, the pattern usually is that features like this get implemented when someone comes along who...
    – goldilocks
    Jul 3, 2014 at 19:20
  • ... 1) Can implement it, 2) Wants to implement it. The fact that no one has indicates, again, that it's a bit of a corner case. There's really an endless list of things that could be described as a "basic action" that could be "implemented as a simple command". There's a much shorter list of people with the time, know-how, and desire to do all the work. Because of that, you often have to go with the flow of what is vs. what is not.
    – goldilocks
    Jul 3, 2014 at 19:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .