Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question
    
A quick workaround would be to use a console-based editor such as nano or vim, which should work without complications. I'm unsure what is causing the error - I had assumed DISPLAY was unset but testing this gives me a different error. –  chronitis Nov 13 '12 at 13:30
    
And moral of the story is to stick with documentation from known sources such as help.ubuntu.com/community –  user25656 Nov 13 '12 at 14:15
    
@vasa1 how is that the moral of the story? Regardless of the merits of following random instructions from the internet, /var/lib/dpkg/status is a file which I should be able to edit with gedit, but currently cannot. Please, if you have a useful answer add it below. –  Bill Cheatham Nov 14 '12 at 17:56
    
Hey, did you get a solution for this? Am having the same problem here. –  Parto Feb 3 at 8:43
    
Found a solution. Check this out askubuntu.com/questions/414785/cant-open-gedit-as-root/414810 –  Parto Feb 3 at 17:11
add comment

1 Answer

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

gksu gedit /var/lib/dpkg/status
share|improve this answer
    
Thanks, I hadn't heard of this. However, using this I get the error Cannot open display. I believe this is an error coming from gedit itself. –  Bill Cheatham Nov 14 '12 at 17:58
    
@BillCheatham That doesn't tally with the situation. If running gedit from the same terminal works, gksu gedit should work. Anyway, try gksu gedit --display=:0 /var/lib/dpkg/status –  Oli Nov 15 '12 at 0:58
    
Hmm.. I agree that it seems like it should, but it just doesn't. gedit opens gedit, gksu gedit gives an error! I think the problems run deeper than I first thought. Thanks for your help though. –  Bill Cheatham Nov 15 '12 at 11:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.