ubuntu 17.10/Debian 10无法运行gparted,错误信息“Gtk-WARNING **: cannot open display: :0.0”

ubuntu 17.04/Debian 10无法运行gparted,错误信息“Gtk-WARNING **: cannot open display: :0.0”,具体信息如下:

~$ sudo gparted
Created symlink /run/systemd/system/-.mount → /dev/null.
Created symlink /run/systemd/system/home-longsky-mytest.mount → /dev/null.
Created symlink /run/systemd/system/media-longsky-A624C9D724C9AB1F.mount → /dev/null.
Created symlink /run/systemd/system/run-user-1000.mount → /dev/null.
Created symlink /run/systemd/system/tmp.mount → /dev/null.
No protocol specified

(gpartedbin:5665): Gtk-WARNING **: cannot open display: :0.0
Removed /run/systemd/system/-.mount.
Removed /run/systemd/system/home-longsky-mytest.mount.
Removed /run/systemd/system/media-longsky-A624C9D724C9AB1F.mount.
Removed /run/systemd/system/run-user-1000.mount.
Removed /run/systemd/system/tmp.mount.

具体的解释以及解决方法如下:

If running Ubuntu 17.10/Debian 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.

为了保证每次启动脚本都可以自动执行,可以把上面的命令加入到.bashrc:

$ sed -i '$a\xhost +SI:localuser:root' ~/.bashrc

参考链接


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

发布者

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注