How to run a GUI application as a different user:
Suppose you are logged into your Linux box as user1 using some X window system already (with GNOME/Unity/..). Now you want to run some gui app as another user, user2.
Run:
xhost +
- Run as the user1. This enables access to user1's X window system from other users. You should see following output: 'access control disabled, clients can connect from any host'sudo su - user2
- Using your favorite terminal, log-in to second user.export DISPLAY=:0.0
- optional for some apps.# sudo mount --bind /home/user1 /home/user2
- optional. This mounts the /home/user1 dir into /home/user2. This is useful if you want to reuse user1's application configs. This can break some other apps sometimes, so only do this if this is really necessary. You can unmount at the end viasudo umount /home/user2
.- execute the gui command:
firefox
I wrote
ego
(Alter Ego) for this use case, it automatically handlesxhost
and Wayland and PulseAudio socket sharing: https://github.com/intgr/egoSo you just run
ego firefox
orego -u user2 firefox
If you run into problems, please open an issue on GitHub. I may be the only user of it, so it hasn't gotten much testing yet.