Ubuntu – Unable to launch gedit with sudo

geditsudox11

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?

Best Answer

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

gksu gedit /var/lib/dpkg/status