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:
Sidenote: To avoid passwords for “su”, you can add this to your
user1 ALL = (root) NOPASSWD: /usr/bin/su
Disclamer: Don’t do that if you care about security.
For GUIs run this:
- disable access control (you will need this package:
(activate access control again with
2) login as user2
sudo su - user2
- set your xserver as output
- Start your program