使用 gedit 编辑文件时终端中显示的错误

rul*_*let 2 gedit command-line

像这样编辑任何文件时:

r@ngf:~$ sudo gedit /etc/default/grub
[sudo] password for r: 

(gedit:1638): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: ?? ??????? ??????? ???? «/root/.local/share/recently-used.xbel.CJP8XV»: ??? ?????? ????? ??? ????????

(gedit:1638): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: ??? ?????? ????? ??? ????????

(gedit:1638): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: ?? ??????? ??????? ???? «/root/.local/share/recently-used.xbel.W8MHYV»: ??? ?????? ????? ??? ????????

(gedit:1638): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: ??? ?????? ????? ??? ????????

(gedit:1638): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: ?? ??????? ??????? ???? «/root/.local/share/recently-used.xbel.DZG7XV»: ??? ?????? ????? ??? ????????

(gedit:1638): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: ??? ?????? ????? ??? ????????
Run Code Online (Sandbox Code Playgroud)

它显示了一些错误,但这并不影响实际编辑 - 文件正常保存。那么这些错误可能意味着什么?

hto*_*que 7

首先,您不应该使用sudoGUI 程序。使用gksudo来代替。

至于警告:它们是无害的。他们只是说 gedit 试图将文件保存在不存在的位置。如果你想让它们消失,你必须创建那个位置:

sudo mkdir -p /root/.local/share
Run Code Online (Sandbox Code Playgroud)

  • 您不必这样做,但强烈建议您这样做。使用`sudo`,`$HOME` 变量将保持为`/home/your_user`,这可能导致文件以root 用户身份写入您的主目录——这是您不想要的。另一方面,使用`gksudo`,`$HOME` 变量将被设置为`/root`。 (3认同)