Tried to find some answer here: Can't launch graphical apps from terminal after updating to 15.10, but it didn't solve my problem.

$ sudo gedit
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.

(gedit:4574): Gtk-WARNING **: cannot open display:

only gedit in terminal works fine. This is my local computer, not a remote system.

  • 4
    Please copy and paste terminal outputs into your question. Images are annoying to read and aren't searchable. Aug 28, 2016 at 18:37
  • Did you try the first comment the question? Aug 28, 2016 at 18:38
  • askubuntu.com/questions/614387/… Aug 28, 2016 at 18:41
  • @Zacharee1 better?
    – Kaz Wolfe
    Aug 28, 2016 at 18:45
  • For me, "sudo gedit" works awesome and I don't need gksudo, despite Zacharee1's insistence it is necessary. Please add more details. 1) from that terminal, can you run gui as your user, not as root? (what returns from gedit). 2) Is the terminal you are showing us on your LOCAL computer, or is it on a remote workstation? If you are on remote, then problem is certainly in your SSH forwarding of X11. Perhaps remote does not offer X11 forwarding, or you didnot ask for it.
    – pauljohn32
    Aug 28, 2016 at 19:09

1 Answer 1


Older post is below, but is still 100% valid.

Mir is not what one would consider stable/ready for operation. Most of the Ubuntu core (such as the below mentioned gksudo and other programs) still relies on X, and can't handle what Mir uses. Until further notice, it's recommended you switch back to X11 unless you have a very good reason to use Mir. If the latter is true, get comfy with sudo nano.

Repeat after me:


*except in extremely rare cases where you know exactly what you're doing.... Or you have a thing for pain. Either/or.

Again. And once more to your dog for good measure.

Instead, use the gksudo command to launch a graphical command with root powers, like so:

gksudo gedit /var/log/auth.log

If your system does not have GKsudo installed on it, install it first with apt:

sudo apt install gksudo

Note that if you're running KDE, use the equivalent kdesudo command.

The reasoning behind this is that sudo does not preserve user-land permissions, which are very often used by graphical applications. For example, if you change the gedit config file after opening it with sudo, you'll have an issue where gedit's config file is now owned by root and is unreadable and/or unwriteable to you, the user.

gksudo takes care of this for you and handles all of the heavy lifting of ensuring that permissions stay the same and don't break anything.

Console commands are different because they often don't save userland configs, and are designed for the use of sudo as opposed to gksudo.

  • 1
    The question they link says gksudo doesn't work. I wonder if it works for OP... Aug 28, 2016 at 18:41
  • @Zacharee1 I'm not sure either, but it's still good advice that the OP should really be aware of.
    – Kaz Wolfe
    Aug 28, 2016 at 18:43
  • well yeah it is :p Aug 28, 2016 at 18:44
  • 1
    Couldn't have said it better myself :) Aug 28, 2016 at 18:55
  • 1
    @cat They do roughly the same thing. pkexec is considered more proper, but old habits die hard.
    – Kaz Wolfe
    Aug 29, 2016 at 4:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .