This question already has an answer here:

I am trying to display the dimensions of an image and then resize them with a program my system says is there called Package ImageMagick- already installed and latest version.

But getting error:

-bash-4.1# display main-bg1.jpg

display: unable to open X server `' @ display.c/DisplayImageCommand/420.

marked as duplicate by slm, Shadur, jasonwryan, Thomas Nyman, Flup Mar 27 '14 at 8:29

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


That message is because you do not have permissions from that shell (root) to display GUI windows to the X server that I presume is running as your normal user.

In another window as your normal user:

$ xhost +

Then try it again. If it still does not work then you can try explicitly setting the $DISPLAY variable in root's shell:

$ export DISPLAY=:0.0

Then repeat your command, display ....

I've logged into a remote server via SSH

If you've logged into some distant server using something like ssh root@remote you'll likely get something like this:

$ ssh -x root@skinner xeyes
Error: Can't open display: 

Now if you use the switch -X:

                                ss of xeyes

You should get the GUI app remotely displayed back to you.

  • sorry I'm not following you. I am running the command as root... – cea Mar 27 '14 at 4:43
  • I tried export DISPLAY=:0.0 but it has made no difference. – cea Mar 27 '14 at 4:44
  • @cea - your desktop is not owned by root, it's some other user that you logged in with. That user owns the X server and you need to grant anyone access to it, xhost +. – slm Mar 27 '14 at 4:44
  • still confused because there is no desktop as such, only my remote server where linux is installed...so do I need to find the program and change the ownership? – cea Mar 27 '14 at 4:46
  • 1
    Ok this might take me a while to work out because it is not opening in my terminal but it an application type terminal- all VERY weird but interesting! thanks :) I will try to work it out. – cea Mar 27 '14 at 5:15

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