Solution to the error: «cannot open display:: 0.0»

There are several occasions when we want to use sudo to run graphical applications with administrative permissions, for example: sudo gparted ó sudo dolphin

And many will have seen this error:

kzkggaara @ geass: ~ / Downloads $ sudo gparted
No protocol specified

(gpartedbin: 6547): Gtk-WARNING **: cannot open display:: 0

Which prevents the application from opening (in this case gparted), a simple step will solve the problem this 😀

We must open a terminal (console, bash, shell, whatever they want to call it ...) and put the following in it:

echo "" >> $HOME/.bashrc && echo "export XAUTHORITY=$HOME/.Xauthority" >> $HOME/.bashrc && cd $HOME && . .bashrc

We push [Enter] and voila, it will be solved 🙂

Simple no? HAHA.

regards


The content of the article adheres to our principles of editorial ethics. To report an error click here!.

17 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Oscar said

    Thanks friend, good and practical tip.

  2.   alez said

    I'm not sure, but I think that this error will appear if "sudo gparted" is used instead of "gksudo gparted" or "kdesudo dolphin", which must be ...

    1.    Courage said

      Those you use in Alt + F2, apart from kdesudo I think it is not, it is kdesu

      1.    Courage said

        Like is gksu

    2.    KZKG ^ Gaara <"Linux said

      Yes indeed, it only appears if it is done with sudo, if it is used gksu o kdesudo it won't appear, the problem is that at least in my Arch I don't have the option to use kdesudo, at least I haven't found it 🙁

  3.   alez said

    http://aur.archlinux.org/packages.php?ID=14357 😉 Be careful that the comments are old so the PKGBUILD is very outdated. Don't look to see if it's in the repositories.
    It is not the same to launch gksu as gksudo, although for practical purposes it is. It's like using su or sudo, the operation is different; in one you log in to the administrator and in the other you simply give rights to a user. In any case, the important thing is to never launch it as a dry sweat.

    1.    KZKG ^ Gaara <"Linux said

      I don't like to use packages from the AUR hehe, not to mention that many times I can't (fault of my ISP) 😀
      Thanks anyway friend 😉

  4.   Rafael Laverde said

    But doing this is not the most correct, it is better to use kdesu, kdesudo, gksu or gksudo as appropriate 🙂
    over here a little explanation that came to mind http://www.kubuntu-es.org/wiki/sistema/por-que-se-debe-usar-kdesu-o-kdesudo-ejecutar-aplicaciones-graficas-terminal-vez-usar-s

    1.    KZKG ^ Gaara <"Linux said

      Hello Rafael, welcome to our site 😀
      The problem with using gksu or kdesudo is that in Arch I don't have them, so I have to resort to sudo.
      Greetings and I hope you like our articles 🙂

  5.   David said

    I get the problem but it is when running google chrome !!
    Is there a similar solution !! ???

    =S

    1.    KZKG ^ Gaara said

      You run [Alt] + [F2] and open Google Chrome, and you get this error? O_O

  6.   elhui2 said

    Excellent after two years you saved me the night, in other sites they said that it was necessary to turn the system over to make Gparted work as superuser. :3

    Thank you.
    Greetings.

  7.   Dante Alighieri said

    This same error appears to me, but when I try to install graphically from any bian cd, can someone tell me how to solve it?

    Thank you

  8.   arantxa said

    What is this supposed to do? I have the same error and I think I did things wrong from the beginning, I executed the following: user @ machine: $ rm -rf /tmp/.X0-lock and when I executed user @ machine: $ Xorg -configure I got an error: /

    I do not know what to do!!

  9.   Anz said

    Thank you very much!
    In my case the error appeared when I launched sudo synaptic.
    Exactly this appeared:
    No protocol specified
    Unable to init server: Could not connect: Connection refused
    (synaptic: 10216): Gtk-WARNING **: cannot open display:: 0

    And before this error I was having problems that .Xauthority did not exist.
    Debian 9 + Gnome3.

  10.   Gonzalo said

    HAHAAJ thank you very much. But it turns out that if you don't have the .Xauthority it's useless.
    But you directed me.

  11.   Eduardo V. said

    You can use

    «`
    touch $ HOME / .bashrc
    «`

    instead of

    «`
    echo "" >> $ HOME / .bashrc
    «`

    touch creates an empty file for you if it does not exist, or updates the file's timestamp otherwise (when it does exist), but does not modify the content in either case, only its modification date.