-   Linux - Software (
-   -   "Gtk-WARNING **: cannot open display: " when I su (

dack_x 08-17-2002 03:51 AM

"Gtk-WARNING **: cannot open display: " when I su
I'm using GNOME2. When I su in terminal and enter a command for a program that uses gtk I get an error like this :
(gedit:8562): Gtk-WARNING **: cannot open display:

What's the deal?


NSKL 08-17-2002 04:41 AM

Since you started X with a different user than with who you are trying to run the program X is not allowing it (security)
Before you su type:
xhost +
xhost + localhost
then su and try to run the app again, it should work now
Hope that helps

dack_x 08-17-2002 04:06 PM

Thanks for the reply.

I entered the command, and it still doesn't work. Any other options or perhaps a configuration file that can be manually edited?

Also perhaps I should note I am using a Linux From Scratch (LFS) system.


dack_x 08-18-2002 12:30 AM

It seems that in addition to using xhost +localhost, using the command export DISPLAY=LOCALHOST:0.0 enables me to open applications that use gtk after suing. I used xhost +localhost as the original user, then after I su I set export DISPLAY=LOCALHOST:0.0

NSKL 08-18-2002 04:28 AM

Yeah i knew about that, but for me i have to do that only if i ssh or telnet into another machine and try to run apps there. If i only su between local users i only need to issue xhost + with original user. I guess its different with LFS.
Thanks for the info anyway!

werner1975 11-03-2007 12:49 PM

Hello, I tried it but I get:

xhost +: Unable to open display localhost:0.0
How can I open a gtk application using sudo?

All times are GMT -5. The time now is 08:24 PM.