关于DISPLAY变量显示问题

DISPLAY用来设置将图形显示到何处

在本机上直接登录之后,startx,可以发现display变量自动设置为

[oracle@kel ~]$ echo $DISPLAY
:0.0
不论使用何种用户来在本机直接登录,都是显示此值

[root@kel ~]# echo $DISPLAY
:0.0

DISPLAY环境变量格式如下host:NumA.NumB, host指Xserver所在的主机主机名或者ip地址, 图形将显示在这一机器上

如果Host为空, 则表示Xserver运行于本机

Xserver默认情况下不允许别的用户的图形程序的图形显示在当前屏幕上. 如果需要别的用户的图形显示在当前屏幕上, 则应以当前登陆的用户, 也就是切换身份前的用户执行

[kel@kel ~]$ xhost +
access control disabled, clients can connect from any host

如果以上不行,则可以尝试一下的环境变量的设置:

第一个:

export DISPLAY=localhost:11.0  --注意修改11的值,监听端口为6011,从而此值为6011-6000=11
根据监听端口来配置:

[oracle@kel ~]$ netstat -tnpl
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 127.0.0.1:40295             0.0.0.0:*                   LISTEN      4862/ocssd.bin      
tcp        0      0 127.0.0.1:37615             0.0.0.0:*                   LISTEN      4862/ocssd.bin      
tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      -                   
tcp        0      0 0.0.0.0:657                 0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:6010              0.0.0.0:*                   LISTEN      -                   
tcp        0      0 127.0.0.1:6011              0.0.0.0:*                   LISTEN      -                   
tcp        0      0 :::22                       :::*                        LISTEN      -                   
tcp        0      0 ::1:6010                    :::*                        LISTEN      -                   
tcp        0      0 ::1:6011                    :::*    


第二个:

[oracle@kel ~]$ IP=`w|grep 'w$'|awk '{printf $3}'`
[oracle@kel ~]$ echo $IP
192.168.1.1
[oracle@kel ~]$ export DISPLAY=$WIP:0.0


posted @ 2014-06-24 11:48  KEL  阅读(7451)  评论(0编辑  收藏  举报