Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 am trying to generate a screenshot of a firefox window in my terminal, but I keep getting an error:

root@host [~]# DISPLAY=:1 firefox http://www.cnn.com & sleep 5 && DISPLAY=:1 import -window root -crop 1264x948+0+25 -quality 90 /usr/local/apache/htdocs/screenshot1.jpg && pkill firefox
[1] 30200
import: unable to open X server `:1' @ import.c/ImportImageCommand/364.

Why is this happening? How can I fix it?

share|improve this question
Can you confirm that Firefox displays on :1? – Gilles Nov 3 '11 at 23:36
How do i check that? – soniccool Nov 3 '11 at 23:49
If you have any other running Firefox (on your main X display, probably), check that they aren't displaying www.cnn.com. If they aren't, and Firefox doesn't produce any error message, chances are good that it is indeed displaying on :1. If you are running Xvfb as your tags suggest, use its -fbdir option and look at the screen with xwud </fbdir-directory/Xvfb_screen0 (and you can even take screenshots with convert /fbdir-directory/Xvfb_screen0 -crop … screenshot1.png). – Gilles Nov 3 '11 at 23:54
Do you have a display :1? Telling ff to display on a new display won't work if it's not there. – Kevin Nov 3 '11 at 23:55
Well i am using DISPLAY=:1 firefox cnn.com & sleep 5 && DISPLAY=:1 import -window root -crop 1264x948+0+25 -quality 90 /usr/local/apache/htdocs/screenshot1.jpg && pkill firefox – soniccool Nov 4 '11 at 2:23

There are two possibilities:

  1. You are not running an xserver on :1. This is probable because most people only run one xserver and by default it is on :0. This can be overcome by starting a xserver on :1. It is not too difficult to run a second xserver on another virtual console. Other popular choices are Xvnc and xvfb which do not depend on hardware.

  2. You are running a xserver on :1 but you do not have permission to use it. Read man xauth.

share|improve this answer

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.