Accessing GUI Applications with “su” in X Windows

There are many solutions for accessing GUI applications (in X Windows). Several are described in this excellent post on the Arch Linux Wiki.

However, I needed a different solution as I frequently “su” to different accounts in the terminal to perform different tasks – I normally don’t just start one application and then exit back to the original user.

I ended up finding an answer in the xhost man pages (go figure). The command below should be run as the user who started the X Windows session. Substitute the actual username of the account for the “su” in place of “USERNAME”.

xhost +"si:localuser:USERNAME"

The si prefix stands for “server interpreted”. This syntax allows us to grant access to a single local user. For more information check out the man pages for xhost and Xsecurity.