I am trying to run
gedit from an SSH terminal on Windows, connected to an Amazon EC2 instance running Ubuntu 12.04 Server and I am getting this error:
Cannot open display:
How do I fix it?
Since you are using Windows on your side, you will need an SSH-client that runs a local X server on Windows to run graphical applications from the server remotely on your screen.
From experience, I would recommend the free MobaXTerm which has this functionality built-in. Please download it and give it a try:
If you get any errors, that's because sometimes a minimal server image may not be set up to allow X-forwarding into it. In that case, please comment and I'll help you solve it; I've done this with lots of minimal VPSs running Ubuntu/Debian.
So you are connecting from your home pc (let's call it your machine) to a server (let's call it server) via ssh? You want to start a program with a graphical window on the server via your machine? If that is correct than by all means read on.
Let's call the program to start
Window on your machine's screen
If you want to see and use gedit's window on your remote machine but start in on the server, you will want your shell session to look like this:
Don't mind the warnings, they are normal - the gedit window will pop up on your remote machine's screen like it would look on the server. The trick is to use the "-X"-option as in
This assumes that you're using an SSH client that supports X11 and that your server has an X-server running (some without a need for GUIs don't run an X-server). Especially on windows this might be an issue as most windows terminal programs don't have X. As izx stated the MobaXTerm is one of the many SSH clients for windows that has an X-Server though.
For a server lacking X11 however, you'd have to install it.
On the server's screen
You can also start an instance on the screen of your server by calling gedit like this:
You have to substitute the right value instead of
Here the most common scenario for that not to work would be if the Server lacked an X11-Server but than it wouldn't have a monitor connected to it or have no graphical user interface and you'd not be reading this :D.
A bit of theory
I'm no expert in this, but the way I think it works is, that each physical screen, i.e. each monitor connected to an individual computer gets a running number in the form of
This number is assigned by the X-Window-System aka X11. That is a layer to provide a network and basic graphical interface that Unity, Gnome, KDE and the like can build upon.
You can see how many displays a given machine has and what numbers are in use by running
*Note: I suppose there is a better way than this for-loop.
If all else fails
Use a shall text editor.
|show 2 more comments|
What con-f-use said.