Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 
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?

share|improve this question
up vote 1 down vote accepted

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
# 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.

share|improve this answer

In the X-Windows session, bring up a terminal and type

xhost +local

Then run your commands in the remote SSH terminal:

export DISPLAY=:0.0
xclock &

That should work correctly.

share|improve this answer
yup that's the problem i don't have an physical access to X-Windows sessions, and there's no vnc on that display so i can't do xhost +local – Troydm Apr 28 '11 at 14:03
Sorry you didn't mention in the question you have noone with physical access to the box - then you're hitting up against the security model of X Windows, and restarting GDM with xauth configured to allow remote connections is the way to go. – Ewan Leith May 3 '11 at 7:50

The display property needs a leading ':'. The whole notation is actually host:displaynum, but the host part can be left off if you want it to show on the localhost. However, the colon can't be left off. So ":0.0" is the value you likely want (and ":0" will likely work too).

When coming in from a remote host, actually the easiest thing to do (because it takes care of X authentication and secures the X connection) is to have ssh handle the X screen forwarding and environment setup for you. You can do this with the -X switch:

ssh -X

After doing that you can examine the DISPLAY variable and you'll see it'll be something like :10.0, because it's actually port-forwarding the remote X display port to the local display.

share|improve this answer
I've tried all combinations of :0.0 and :0 and even :1.0 and :1 and 1.0 but none of them worked – Troydm Apr 28 '11 at 13:39
If this is on a remote then you definitely need the host name, with proper xauthentication set up. xauth is sort of annoying to get working, so once you get it running save the results in a script. I'll also add a note about SSH itself in an updated version of the above. – Wes Hardaker Apr 28 '11 at 14:17

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.