Can you open a virtual desktop for another user on the same system?

Let’s say I have a bare metal Manjaro install with two user accounts: User A and User B.

When logged into the DE as User A, would it be possible to open a (windowed) virtual desktop as User B?

If so, what application (and/or DE?) do I need for that? Can I then also copy/paste between the ‘virtual’ and the ‘real’ desktop?

Hi!
I’m a little confuse. Are you asking about virtual machines or virtual desktops, those aren’t the same thing. If you want you use 2 different users in the same system at the same time, I’d say no, but you are able to copy/paste any file from one user to another using root privileges. Let’s say that you want to copy test.txt from home dir of user 2 into home dir of user 1.
‘’’ sudo cp /home/user2/test.txt /home/user1/```
The change the permissions of the file to user 1

Thanks! I am not asking about virtual machines.

I would like to open a virtual desktop for User B (who is a user on the same system/install) while logged into the desktop of User A.

Ideally I can use a shared clipboard between the ‘real’ desktop of User A and the ‘virtual’ desktop of User B.

I have never seen this scenario described before, which is why I am asking.

Hi!

Well on Linux it is not “virtually”, but is more a permission management thing. It can be done with the command su. An example:

We have a user1 and a user2. To open a program as user2 when you logged in as user1, then run this for example:

su --login --command "whoami" user2

Then type the password of user2 and the command “whoami” will be run as user2. That works with every command.

For more information:

man su

Sidenote: To avoid passwords for “su”, you can add this to your /etc/sudoers file:

user1 ALL = (root) NOPASSWD: /usr/bin/su

Disclamer: Don’t do that if you care about security.

For GUIs run this:

  1. disable access control (you will need this package: xorg-xhost)
xhost +

(activate access control again with xhost -)
2) login as user2

sudo su - user2
  1. set your xserver as output
export DISPLAY=:0.0
  1. Start your program
firefox

or

thunar

or whatever

Thanks!

Would I be able to launch a GUI application that way? This works with CLI based commands, but when I try to launch Chromium or Firefox, it throws an error “Unable to open X display” or “No DISPLAY environment variable specified”.

Or do I need to follow all the steps and start another xhost to be able to run a GUI application as another user?

In that case, what are the security implications of “disabling access control” with xorg-xhost?

Nope as i described. You need to open you xserver.

Well it opens the port, so that anyone in your local intranet or if no router with firewall is there, also the whole world could connect to your xserver. :innocent:

Just keep sure you have a firewall and it is configured properly.

Here is short example, how you can do it in one line:

xhost + && sudo su -l -c "export DISPLAY=:0.0; firefox" user2 && xhost -

As long as firefox is runnng, the xserver is open, when you close it, the access control of the xserver is enabled again