Grant a single user access to your x session


Say you're logged into your laptop as lisa and want to give another user on the same machine access to your X session, i.e. open graphical applications. For years, I disabled X's authentication mechanism alltogeter with:

$ whoami
lisa
$ xhost +

The john user could now start graphical appliations:

$ whoami
john
$ export DISPLAY=:0
$ xeyes &

However, there's a better way. To grant only john access to your graphical dispaly, instead do:

$ whoami
lisa
$ xhost +SI:localuser:john

Now, as john, export the display to the local one and start the graphical application:

$ whoami
john
$ export DISPLAY=:0
$ xeyes &

You can turn off access to your X server by:

$ xhost -

Licensed under CC BY Creative Commons License ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🐦 @torsteinkrause