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 -

~ /home 🏠 ~ talks 💬 ~ bash ~ craftsmanship ~ db ~ dongxi ~ emacs ~ escenic ~ iam ~ java ~ js ~ language ~ latex ~ ldap ~ life ~ linux ~ llm ~ mac-os-x ~ mt-foo ~ network ~ norsk ~ python ~ quotes ~ running ~ security ~ travel ~ unix ~ various ~ vcs ~ webdesign ~ windows ~ discoveries ~ cv 🧙 ~

Licensed under CC BY Creative Commons License ~ 📡 RSS feed ~ ✉ torstein.k.johansen @ gmail ~ 🐘 @skybert@hachyderm.io ~ 🎥 youtube.com/@skybert