linux解决xhost: unable to open display ""

在Linux下设置xhost方法步骤linux

第一步:用root登录linux,启动vnc服务;app

root@gao-virtual-machine:~# vncserver
未找到 'vncserver' 命令,您要输入的是不是:
命令 'vnc4server' 来自于包 'vnc4server' (universe)spa

执行以后,根据以上提示从新执行vnc4server命令日志

提示:server

程序“vnc4server”还没有安装。 您能够使用如下命令安装:
apt-get install vnc4serverci

再执行apt-get install vnc4server命令进行安装,安装完成后,从新执行vnc4serverget

第二步:根据vnc起来的端口,设置export DISPLAY=localhost:1(1表示vnc在第一个tty上启动的),vnc的启动信息见附件1;io

第三步:执行xhost +,而且提示“access control disabled, clients can connect from any host”才正确。cli

linux下的操做日志以下:file

root@gao-virtual-machine:~# vnc4server

root@gao-virtual-machine:~# apt-get install vnc4server
程序“vnc4server”还没有安装。 您能够使用如下命令安装:
apt-get install vnc4server

root@gao-virtual-machine:~# vnc4server

New 'gao-virtual-machine:2 (root)' desktop is gao-virtual-machine:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/gao-virtual-machine:2.log

[root@localhost ~]# export DISPLAY=localhost:2

[root@localhost ~]# xhost +

access control disabled, clients can connect from any host 

在设置xhost时,出现了unable的问题。使用上诉方法就能够搞定。

相关文章
相关标签/搜索