All of the sudden gksu stopped working for me:
~$ gksu gparted
(gpartedbin:24252): Gtk-WARNING **: cannot open display: :0
The same happens with gparted-pkexec
:
~$ gparted-pkexec
No protocol specified
(gpartedbin:25454): Gtk-WARNING **: cannot open display: :0
What could possibly be causing this?
I am not running this through SSH or VNC. This is localhost in a normal terminal window.
If running Ubuntu 17.10 or newer, this issue can arise when an application has not been updated with full support for Wayland. As a workaround until the application is updated, you can run
which will allow the
root
user to display applications on your desktop. Also see this Q&A for other possible workarounds: Why don't gksu/gksudo or launching a graphical application with sudo work with Wayland?source
Try running
xhost +localhost
in your terminal, and then running the command again. This lets all users on your system (i.e. root) open windows on your screen. Make sure to use +localhost and not simply +, as it's more secure to allow connections from only localhost than from anywhere.To make this permanent, edit the
~/.xinitrc
file like this:Run
gedit ~/.xinitrc
Edit the file to look like this (it should be empty at the start):
Now save the file, log out and log in. Now everything should run just fine with sudo.
I can't reproduce your problem on 14.04, but this has worked for me in the past when sudo / gksu threw this error.
Sources:
Execute the following in your terminal:
Add the following line at the end.
xhost +
fixed my problembut Be aware that
xhost +
completely deactivates authentication and allows everyone to access all application on your screen...xhost +si:localuser:root
seems to work similar with proper authenticationI solve it by simply running in the terminal ,
Looks like GTK+ root password dialog confused with x server settings