Timeline for Running GUI application as another (non-root) user
Current License: CC BY-SA 3.0
21 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 6, 2020 at 15:04 | comment | added | Peter Kay |
More xhost details and options (debian based solydX): This will allow any local user to access the display: xhost +local: From the man page: "The local family specifies all the local connections at once. However, the server interpreted address "si:localuser:username" can be used to specify a single local user" So this worked for me: xhost +si:localuser:[username]
|
|
| Aug 20, 2018 at 0:44 | comment | added | giusti |
I am running Debian "testing" with Xfce. In the past, xhost + was enough, but now I realize that I must manually set and export $DISPLAY. Does anybody know why?
|
|
| Feb 3, 2018 at 7:24 | comment | added | Braden Best |
It's interesting to note that the only reason su ing to another user and executing a GUI program from that shell doesn't work is because $XAUTHORITY is set to user1's .Xauthority, which cannot normally be read by user2. Thus, running chmod o+r ~/.Xauthority as user1 and then running XAUTHORITY=/home/<user1>/.Xauthority DISPLAY=<display> <program> as user2 is a quick hack-y way to get around this. Even without any form of xhost +, from my experiments. Thus, I wrote a convenient script.
|
|
| Nov 9, 2017 at 1:06 | review | Suggested edits | |||
| Nov 9, 2017 at 2:38 | |||||
| Mar 17, 2017 at 4:46 | comment | added | robartsd |
xhost + will allow any user on any host that can connect to your x-server to access your screen. xhost +SI:localuser:user2 works for me on Debian.
|
|
| Mar 2, 2017 at 8:47 | comment | added | Vishal Kumar Sahu | I didn't understand the commands but it worked perfectly. :) | |
| Apr 27, 2015 at 12:38 | comment | added | Wilf | Also described here | |
| Apr 21, 2015 at 11:01 | comment | added | Wilf |
Oh, found something. On Fedora 21 running xhost gives a list in the format SI:localuser:USERNAME, so xhost SI:localuser:user2 should work. Oh and the display of the user can be found using w.
|
|
| Apr 21, 2015 at 10:23 | comment | added | Wilf |
@slm - is it possible to specify a user at all? Each time is gives a error about a bad hostname - I also tried various incantations of xhost [email protected] and those didn't work (the output said the user had been added to the access control list though... - I am trying to test something under a different user without logging out :) xhost + does work on Fedora 21 though, and I ran xhost - after I finished as I think it returns it to normal.
|
|
| Jan 11, 2014 at 22:41 | vote | accept | sashoalm | ||
| Jan 11, 2014 at 22:40 | comment | added | slm♦ | @satuon - updated. | |
| Jan 11, 2014 at 22:40 | history | edited | slm♦ | CC BY-SA 3.0 |
deleted 14 characters in body
|
| Jan 11, 2014 at 22:27 | comment | added | sashoalm |
Thanks, xhost + works, and nothing else seems to be needed (no need to set $DISPLAY). Can you update your answer, and I'll accept it?
|
|
| Jan 11, 2014 at 12:58 | comment | added | slm♦ |
@satuon - instead of xhost +user2 try xhost + to allow anyone, just to see if that works. When in user1's desktop, in a shell type echo $DISPLAY, and confirm that they're on :0.0.
|
|
| Jan 11, 2014 at 10:15 | comment | added | sashoalm |
But even after adding the user with xhost, and specifying export DISPLAY=:0.0, running leafpad still gives me No protocol specified leafpad: Cannot open display:, and fails to run. I found this link at linuxquestions.org/questions/linux-newbie-8/…, which says that there are some magic cookies and xauth. Have you tested that those things work on your computer btw? Maybe something's different with my configuration? I'm on Debian+LXDE.
|
|
| Jan 11, 2014 at 10:10 | comment | added | sashoalm |
xhost +user2 still gives me this error - xhost: bad hostname "user2". I googled some, and it seems I need to do xhost +user2@laptop or xhost +user2@localhost, not sure which. Then it says xhost +user2@localhost being added to access control list.
|
|
| Jan 11, 2014 at 1:13 | comment | added | slm♦ | @satuon - OK, I'm going to leave it in the answer so that other people that may come across this Q&A in the future understand that that needs to be explicitly done. See updates. | |
| Jan 11, 2014 at 1:12 | history | edited | slm♦ | CC BY-SA 3.0 |
added 264 characters in body
|
| Jan 10, 2014 at 22:01 | comment | added | sashoalm |
Btw I updated my question, you can remove the part about su - user2 now.
|
|
| Jan 10, 2014 at 21:50 | comment | added | sashoalm |
When should I execute xhost +user2? From user1 context or from user2 context? Both gave me an error - xhost: bad hostname "user2" when executing from user1, and No protocol specified xhost: unable to open display ":0" when executed from user2.
|
|
| Jan 10, 2014 at 20:37 | history | answered | slm♦ | CC BY-SA 3.0 |