Running GUI programs as other users

Asked by Bo Elliot Miller

I am trying to run a GUI based program from my current user account as another user. The issue I am having is that when running this program the terminal throws an error at me:
"Warning: Unable to open display ':0.0'. You will not be able to display graphics on the screen."
The program then proceeds to run in comandline form with no option to display any form of ghraphic. I have tried using "su" to log in as the user and "sudo -u USERNAME program", but both give the result mentioned above. I have also tried exporting the display with "export DISPLAY=SYSTEMNAME:port_number", but when I try to run the program agian it just spits out "Warning: Unable to open display 'SYSTEMNAME:port_number'. You will not be able to display graphics on the screen." Thus I am back to CLI. Is there a way to launch the program with the GUI from an account where the program does not originate?

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu xorg Edit question
Assignee:
No assignee Edit question
Solved by:
Thomas Krüger
Solved:
Last query:
Last reply:
Revision history for this message
actionparsnip (andrew-woodhead666) said :
#1

Are you on the local system or are you connected via SSH?

Revision history for this message
Bo Elliot Miller (millerbe31) said :
#2

I am on the local system, but the bigger purpose is to give access to the program to users that will be accessing the it remotely through multiple GUI based VNC sessions.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#3

Why not just use X forwarding and you can run GUI apps, the command will run on the server side but be displayed on the client. Much like how Citrix runs.

If you run:

export DISPLAY 0.0
su username -c program

Should work.

Revision history for this message
Bo Elliot Miller (millerbe31) said :
#4

Is that the syntax fro starting X forwarding, or is there something else I need to do to get X forwarding working. I ask becasue I tried:

export DISPLAY=0.0
su username
program

and got the same results as before.

Revision history for this message
actionparsnip (andrew-woodhead666) said :
#5

Try:

su username
export DISPLAY=0.0
program

Revision history for this message
Bo Elliot Miller (millerbe31) said :
#6

Unfortunately, I am getting the same results from that comand order. Though, I have fortunately found a workaround for the program that I needed this for, so it doesn't look like I need an answer to this question. I would still be interested to see if there is a solution, but it doesn't look like it is needed. Thanks for all of your help actionparsnip.

Revision history for this message
Best Thomas Krüger (thkrueger) said :
#7

This is actually a safety feature. A non-priviliged user can not access the X server session of an other user.
I know you can do that on Windows, but it's one of the causes Windows is not really secure.

łoptions:
 - login as the other user in a seperate session, Ubuntu can run several sessions at the same time
 - install the openssh server and connect to localhost as the other user with the -X parameter

Revision history for this message
Bo Elliot Miller (millerbe31) said :
#8

Thanks. I am glad to know with finality that I can't do it. I am also glad that there is a good reason for not being able to.