7

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-6.5.4.7-7.el6_5.i686 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.

cea
  • 1,543

1 Answers1

8

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.

slm
  • 369,824
  • sorry I'm not following you. I am running the command as root... – cea Mar 27 '14 at 04:43
  • I tried export DISPLAY=:0.0 but it has made no difference. – cea Mar 27 '14 at 04: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 04: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 04:46
  • @cea - nope. Can you update your Q, you're logged into a remote server? The situation is important to understanding how to fix it. – slm Mar 27 '14 at 04:47
  • sorry update my which? – cea Mar 27 '14 at 04:48
  • @cea - for example, can we assume that you used ssh root@remoteserver to get into that system? – slm Mar 27 '14 at 04:48
  • yes that's right – cea Mar 27 '14 at 04:48
  • So then you'll likely need to allow X traffic to come back over your SSH tunnel. Try ssh -X root@remote. – slm Mar 27 '14 at 04:49
  • you mean logout and log back in as such? – cea Mar 27 '14 at 04:49
  • @cea - correct. – slm Mar 27 '14 at 04:49
  • Oh! that has opened it ON my desktop. What is going on here? I am new to this completely. – cea Mar 27 '14 at 04:51
  • still says cannot connect? – cea Mar 27 '14 at 04:55
  • @cea - OK one more time. Exit that connection and now try this. (1) xhost + (2) ssh -X root@remote (3) display .... – slm Mar 27 '14 at 04:56
  • I did all of the above but still says cannot connect even though I can plainly see the server in my desktop window, are you saying I need to now re login the normal way? – cea Mar 27 '14 at 05:07
  • NEVERMIND! I will have to go and read about this. Sorry and I will just assume you have the answer correct as I'm sure you do. – cea Mar 27 '14 at 05:10
  • @cea - take a look at these 2 Q&A's they cover everything you're asking about: Open a window on a remote X display (why “Cannot open display”)? & Cannot connect to X server :0.0 as superuser – slm Mar 27 '14 at 05:10
  • @cea - getting the remote display working can be one of the trickier things to get initially. Look over those 2 links and if you're still stuck I'll be around and can try and give you more detailed help. I'm bumping into my bed time now. 8-) – slm Mar 27 '14 at 05:12
  • WAIT it has opened another window!!! called xterm but that says display command not found – cea Mar 27 '14 at 05:13
  • 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 05:15
  • @cea - I'll be around if you need more help. – slm Mar 27 '14 at 05:16
  • @slm: I know this is old news, but I’m puzzled by the order of your first few paragraphs.   (1) The error message in the question appears to be complaining that $DISPLAY is not set (display: unable to open X server ‘’), so setting DISPLAY should be the first thing you try.  Also, (2) if $DISPLAY is not set correctly, running xhost won’t help — so, again, ensuring that $DISPLAY is set correctly should be the first step, in general. – G-Man Says 'Reinstate Monica' Jul 03 '15 at 01:50
  • @G-Man - probably b/c I wrote that A'er at 4am in the morning 8-). Yeah the advice about xhost + was essentially unnecessary in this particular situation. I generally give this advice as a package and have become immune to the actual order one gets the messages in. The 2 fundamental problems w/ remote displaying one will run into are (1) Xserver running locally does not have permissions to receive incoming connections (xhost +), and (2) the remote server is not configured to properly send data to me. – slm Jul 03 '15 at 02:01