Ubuntu – gksu: Gtk-WARNING **: cannot open display: :0


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.

Best Answer

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

xhost +SI:localuser:root

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?