Ubuntu local display

Ubuntu

I have an Ubuntu server running gdm with graphical user session in it.
I also have an open ssh console from remote host on that server.

I want to run x windows application from that remote console.

export DISPLAY=0.0 
xclock
Error: Can't open display: 0.0

How can i do that without restarting gdm and enabling remote connections with xhost +, is there any way? Can't i use local named pipes to connect to display server?

Best Answer

You'll need to run the command you want to display as the same user who is logged in. In the case of having gdm running, that would be root.

# DISPLAY=:0.0 yourcommand
or
# export DISPLAY=:0.0
# yourcommand

If you want to allow all other users on the local machine to use the display, run this as the display's current user:

xhost +local:

(nothing after the :)

This could be an issue if there are other users which you do not want to allow to use the display. In this case, you need to use xauth for more fine-grained control.