X server error when GTK+ apps as sudo from terminal [SOLVED]

Often I hit with this error message on running apps like gpartd, partitionmanager as sudo from the root/user shell.
Case
$sudo gpartd
No protocol specified
(gpartedbin:8630): Gtk-WARNING **: cannot open display: :0

Fix
Open up a new terminal, and give
$ export XAUTHORITY=/home/<username>/.Xauthority
That would fix it :). Thanks!
PS. Now to make it permanent,
sudo nano .zshrc ( can be .bashrc, if you use bash )
add the following line to the end of the file
$ export XAUTHORITY=/home/<username>/.Xauthority
save & exit
sudo source .zshrc

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s