Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save mardukbp/6b5a12cc650b6a65fc42cc36167856e8 to your computer and use it in GitHub Desktop.
Save mardukbp/6b5a12cc650b6a65fc42cc36167856e8 to your computer and use it in GitHub Desktop.
How to run a GUI application as a different user?

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:

  1. 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'
  2. sudo su - user2 - Using your favorite terminal, log-in to second user.
  3. export DISPLAY=:0.0 - optional for some apps.
  4. # 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 via sudo umount /home/user2.
  5. execute the gui command:

firefox

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment