前言:
在使用sudo gedit的时候弹出,
No protocol specified
Unable to init server: 无法连接: 拒绝连接
(gedit:26479): Gtk-WARNING **: 08:15:41.607: cannot open display: :0
原因:
当使用sudo用到另外一个用户运行某个程序,而这个程序又要有图形显示的时候,就有可能有下面提示:
No protocol specified
Unable to init server: 无法连接: 拒绝连接
(gedit:26479): Gtk-WARNING **: 08:15:41.607: cannot open display: :0
解决办法
这是因为Xserver默认情况下不允许别的用户的图形程序的图形显示在当前屏幕上. 如果需要别的用户的图形显示在当前屏幕上, 则应以当前登陆的用户, 也就是切换身份前的用户执行如下命令。
xhost +
通过执行这条命令,就授予了其它用户访问当前屏幕的权限,于是就可以以另外的用户运行需要运行的程序了。