ubuntu 18.04 gedit不能使用以及xhost: unable to open display问题

1. SecureCRT上使用gedit不好用

因为gedit是基于窗口模式啊,而使用secureCRT进行ssh远程操作是在终端下,所以gedit当然是不好用的,可怜我还当个问题准备解决。。。
终端模式下编辑文本应该使用vim,也可以是vi。

2. Gtk-WARNING **: 10:39:36.773: cannot open display:

服务器远端GUI图形用户界面使用的是VNC Viewer

在使用gedit打开一个文件时,出现如下提示:

Unable to init server: Could not connect: Connection refused
(gedit:3278): Gtk-WARNING **: 10:39:36.773: cannot open display: 

原因:X server默认情况下不允许别的用户的图形程序的图形显示在当前屏幕上
解决办法:执行xhost +,授予其它用户访问当前屏幕的权限

3. xhost: unable to open display “”

而此时又出现了如下提示:

xhost:  unable to open display ""

解决办法:root权限下,依次执行

vncserver :1
export DISPLAY=localhost:1
xhost +

实际操作过程如下:

root@Server:~$ vncserver :1

New 'Server:1 (root)' desktop is Server:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/Server:1.log

root@Server:~# export DISPLAY=localhost:1
root@Server:~# xhost +
access control disabled, clients can connect from any host

出现access control disabled, clients can connect from any host即为成功
这里比如打开tomcat中bin文件夹下的startup.sh文件

root@Server:/usr/local/apache-tomcat-8.5.33/bin# gedit startup.sh 

成功弹出界面
gedit打开文本

学习链接:https://blog.csdn.net/preamble_1/article/details/70883978

猜你喜欢

转载自blog.csdn.net/WingWudan/article/details/82864472