环境: Ubuntu 20.04.2 LTS Desktop

1.问题描述

尝试修改环境变量,使用 sudo gedit /etc/profile报错:

~$ sudo gedit /etc/profile
No protocol specified
Unable to init server: Could not connect: Connection refused

(gedit:4331): Gtk-WARNING **: 09:58:47.068: cannot open display: :10.0

** (gedit:4391): WARNING **: 10:11:05.322: Could not load theme icon text-x-generic: Icon 'text-x-generic' not present in theme Adwaita

至于出现的原因,网上的说法是:
     当使用su到另外一个用户运行某个程序,而这个程序又要有图形显示的时候,就有可能有上述的提示。因为在默认情况下,系统不允许别的用户的图形程序的图形显示在当前屏幕上。

     放到这里,可能是因为尝试修改的是该系统下所有用户的环境变量,而不是使用 ~/.profile只对当前用户的环境变量修改导致出现该提示。

2.解决方案

~$ xhost local:gedit
non-network local connections being added to access control list

done

标签: none

添加新评论