Unable to open any graphical app with "sudo"
Solution 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:
NEVER RUN GRAPHICAL PROGRAMS WITH
sudo
! *
*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
.