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 this little problem 

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 that's it, it will be solved 

Simple no? HAHA.

regards