We help IT Professionals succeed at work.

display on ubuntu

Medium Priority
33 Views
Last Modified: 2020-02-20
i try to run firefox on ubuntu server 18. i wrote
export DISPLAY=:0
then firefox &

Failed to connect to Mir: Failed to connect to server socket: No such file or directory
Unable to init server: Could not connect: Connection refused
Error: cannot open display: :0
Comment
Watch Question

David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Unlikely this will work on a server version of Ubuntu, unless you've installed additional software.

On a Desktop install, you'll have a display system... of some sort... installed...

Servers are headless. No display. So some sort of pseudo/fake display must be setup.

Maybe you can explain what you hope to accomplish by running Firefox on a server, since you'll have no display to see any rendered content.

This will provide clues to assist you.
CERTIFIED EXPERT

Commented:
You need to start an X server first.  You may have to install X before you can start it.

If you're connecting remotely through ssh, you must also enable X tunneling.
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
You can use the X server on any machine in the network, provided you started X with the -listen argument on that system. This was the default until a few years ago. Then do e.g. DISPLAY=somehost.local.net firefox& and interact with Firefox on the nominated system
CERTIFIED EXPERT

Commented:
If you have to manually set DISPLAY=somehost.local.net, then you're doing something wrong.  A properly installed X server package will have that automatically configured on the vast majority of Linux Distros.  I've only had to do that on systems where someone didn't install X and all the dependencies correctly.
Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
@serialband: You miss the point. This is for some system without an X server. (Or it can have one, but for some reason you want to use another display).
CERTIFIED EXPERT

Commented:

Hi, 


Try to set the display to 0.0 instead of 0 as the first number is the Xserver number (port 6000+Xserver_number).T

The second number is the screen number that is managed by this particular server. Note that a single Xserver can manage a lot of screens. If you don't care about screens, empty is the same as 0.


In general:


- Remove "-nolisten tcp" from /etc/X11/xinit/xserverrc  

- Add "xserver-allow-tcp=true" into /etc/lightdm/lightdm.conf

- Restart X


Then allow a remote connection to allow to connect locally. So on the local machine: 

xhost +


Set the display with your local ip on the remote server:

export DISPLAY=local_ip:0.0


Then test on the remote server:

/usr/bin/X11/xclock


Cheers

Duncan RoeSoftware Developer
CERTIFIED EXPERT

Commented:
I don't like xhost + because Tk will not allow the send command if you do that. I use an expect script to run xauth on the X server system to get the MIT-MAGIC-COOKIE for that system then run xauth locally to add a record for the X server system with that key
CERTIFIED EXPERT

Commented:
xhosts + was used in the days of insecure telnet and needs to go away.  You're basically telling the user to unlock x so that anyone able to ping the system can view their x session.  That should only ever be used for a very brief test and then immediately turned off.  That MIT-MAGIC-COOKIE used to be stored as plain text.  They've changed it, but it's still easy enough to access and view that xhost + session that someone just opened.


If anyone is using it for regular connections on a regular basis, then they don't really know unix and shouldn't be allowed access to the systems.  I'd immediately restrict their access and force them into basic security training.  It's not that hard to use ssh or ssl properly.
CERTIFIED EXPERT

Commented:
Hi,

mit magic cookies are transferred as a flat files basically..that's even worse. Anyone who grabs hold of it during verification can spoof his way in saying open sesame. It's just a client server cookie compare.

That's why you export to your local ip adress for your own session. Unless you leave your own desktop unnattended you're out of luck opening a remote x session.

Cheers