2

While trying to follow these instructions, I encountered the following error while attempting what seems like a simple sudo edit operation:

$  sudo gedit /var/lib/dpkg/status

** (gedit:14898): WARNING **: Command line `dbus-launch --autolaunch=0bd873023a78bdb34ca1b9650000000b --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
Cannot open display: 
Run 'gedit --help' to see a full list of available command line options.

Running the same without sudo correctly launches gedit, but of course without editing ability. Does anyone have any idea what is going on?

2 Answers2

7

You should be using gksu to launch graphical things as root.

gksu gedit /var/lib/dpkg/status
Oli
  • 299,380
1

There is a known bug in 16.04 preventing root gedit from displaying the menu bar, making it somewhat useless.

The solution is to preserve environment variables while launching gedit. (Nautilus and Terminal have the same problem and fix, by the way).

gksu -k gedit
Amir Uval
  • 1,161