Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

When I ssh to a server using -X, I am always confused about which display number I should export. It seems to me sometimes the display number has been used by something, so what I can do is only go through:

export DISPLAY=localhost:0 && xclock  
export DISPLAY=localhost:1 && xclock  
export DISPLAY=localhost:2 && xclock  
export DISPLAY=localhost:...

until the clock appears. I will then use that display number. Each time I log into the server, the display number which is able to tunnel the GUI data correctly would be different.

share|improve this question
up vote 2 down vote accepted

sshd automatically sets $DISPLAY on the server side when X forwarding is enabled; there should be no reason for you to override its value.

share|improve this answer
Thanks! I will have to wait till next week when i can access the server and reply you back! – insidepower Dec 27 '10 at 9:57
It works as you said. Thanks for the answer! – insidepower Jan 5 '11 at 2:57

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.