You're happly running a desktop X11 session as user anne
; but you want to be able to run an X11 application in that session as bob
, but wehn you try to do this you get:
X-Server access is denied on host
Many articles will recommend disabling the xhost
access controls. DON'T do this, as it allows anyone to connect to your X11 session. We can easily just allow bob
to do that with:
xhost +si:localuser:bob
This allows just bob
to access your current X11 display. Check your current display with:
echo "DISPLAY=$DISPLAY"
and note it (usually it's something like :0
; that's the value we will use in the next couple example commands).
Then you can:
su bob
export DISPLAY=:0
xterm
Of course replace :0
with the actual value you noted from above, and xterm
with whatever X11 application you're starting. That simple.