xhost命令介绍+0.1/1.0(引)

在ixpub上看到很多朋友遇到关于xhost命令的问题,例如报错:xhostunabletoopendisplay

很多没有得到很好哦解决,其实这个命令的使用很简单,只要熟悉了命令的使用,就不会有这么多问题了,下面先说说这个命令的使用,然后结合问题,说说遇到这类问题的解决办法.

xhost命令

用途
控制什么人可以访问当前主机上的增强 X-Windows。

语法
xhost[  + |  - ] [Name ]

描述
xhost命令添加或删除 X 服务器接受连接的机器列表上的主机名。

该命令必须从有图形显示连接的机器上运行。可以通过使用 -Host 参数,从访问列表中除去一个名称。不要从访问列表中除去当前的名称。如果已经这样做了,请在作出任何更改之前注销系统。

输入无变量的xhost命令将显示访问 X 服务器的当前主机名,并显示一条消息表明访问是否已启用。

[root@vs022 StageR122]# xhost
access control disabled, clients can connect from any host
INET:10.52.160.168
INET:10.214.0.6
INET:144.20.30.96
INET:192.168.126.1
INET:192.168.15.1
之所以会显示这么多,是因为我电脑现在连有好多网卡,并有Vmware虚拟网卡,还有连接vpn等。。


为了安全起见,只能从控制主机运行影响访问控制的选项。对于工作站来说,这台机器也就是服务器。对于 X 终端来说,这台机器是登录主机。

要在缺省情况下启用远程名称,可以在 /etc/X?.hosts 文件中定义名称,其中 ? 为启用访问的显示器号。

例如,显示器 jeanne:0 可以由使用 jeanne 的缺省主机名的系统上的 /etc/X0.hosts 文件中定义的系统访问。在显示名称和文件名中,0 表明已定义的远程系统允许通过增强 X-Windows 访问的显示器号。

标志

+Name 定义要添加到 X 服务器访问列表的主机名(可以选用加号标记)。
- Name 定义要从 X 服务器访问列表中除去的主机名。已有的连接没有被中断,但将拒绝新的连接请求。注意:可以除去当前的机器;然而,不允许进行进一步的连接(包括试图将其添加回来)。再一次启用本地连接的唯一方法就是将服务器复位(因此也会中断所有连接)。
+ 指定访问不受限制。访问控制被关闭。
- 打开访问控制。

完整的 Name 有以下 family:name 语法:

inet
因特网主机
local
只包含一个名称,空字符串
注: 该系列是区分大小写的。名称的格式随系列而不同.

只要了解了命令的使用,上面的问题就迎刃而解了,一般在安装oracle的时候会出现这个问题,因为oracle的安装需要图形界面的支持!

遇到这类问题的一般解决办法是:

先在rootxhost+

如何是在远程客户端启动桌面服务,需要设置客户机的DISPLAY(exportDISPLAY=IP(客户端的IP地址,你要设成别的地址,那你就看不到图形):0.0

如果是在本机执行的话,直接到oracle图形用户下执行export DISPLAY

如果上述设置后,还是不能启动图形的话,就要检查系统图形界面支持的问题了,例如是否安装了图形程序,是否有权限执行图形程序.或者系统时候屏蔽了图形功能等等.

最后执行./runInstaller就行了。

 

标  题: Re: 请问命令xhost的作用和内部机制是干啥的 

xhost 是用来控制X server访问权限的。 
通常当你从hostA登陆到hostB上运行hostB上的应用程序时, 
做为应用程序来说,hostA是client,但是作为图形来说, 
是在hostA上显示的,需要使用hostA的Xserver,所以hostA是 
server.因此在登陆到hostB前,需要在hostA上运行xhost + 
来使其它用户能够访问hostA的Xserver. 

xhost + 是使所有用户都能访问Xserver. 
xhost + ip使ip上的用户能够访问Xserver. 
xhost + nis:user@domain使domain上的nis用户user能够访问 
xhost + inet:user@domain使domain上的inet用户能够访问。 
还有一些option,还是仔细看一下manual吧。

 

[root@ds1 ~]# xhost +192.168.130.196
192.168.130.196 being added to access control list
[root@ds1 ~]# su - oracle
[oracle@ds1 ~]$ xhost +192.168.130.196
192.168.130.196 being added to access control list

 

后来注销切换到oracle的用户登录,则可以运行runInstall了

[oracle@ds1 ~]$ xhost +192.168.130.196
192.168.130.196 being added to access control list
[oracle@ds1 ~]$ cd clusterware/
[oracle@ds1 clusterware]$ ls
cluvfy  doc  install  response  rpm runInstaller  stage  upgrade  welcome.html
[oracle@ds1 clusterware]$ ll
总计 72
drwxr-xr-x 2 oracle oinstall 4096 2005-07-03cluvfy
drwxr-xr-x 6 oracle oinstall 4096 2005-07-03doc
drwxr-xr-x 4 oracle oinstall 4096 2005-07-03install
drwxr-xr-x 2 oracle oinstall 4096 2005-07-03response
drwxr-xr-x 2 oracle oinstall 4096 2005-07-03rpm
-rwxr-xr-x 1 oracle oinstall 1328 2005-07-03runInstaller
drwxr-xr-x 9 oracle oinstall 4096 2005-07-03stage
drwxr-xr-x 2 oracle oinstall 4096 2005-07-03upgrade
-rw-r--r-- 1 oracle oinstall 3445 2005-07-03welcome.html
[oracle@ds1 clusterware]$ ssh ds1 date;ssh ds2 date
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
2008年 06月 21日 星期六 08:22:41 CST
Enter passphrase for key '/home/oracle/.ssh/id_rsa':
2008年 06月 21日 星期六 08:22:45CST
[oracle@ds1 clusterware]$ ./runInstaller &

 

Display Names

From the user's perspective, every X server has a display name of the form:

hostname:displaynumber.screennumber

This information is used by the application to determine how it should connect to the server and which screen it should use by default (on displays with multiple monitors):

hostname
The hostname specifies the name of the machine to which the display is physically connected. If the hostname is not given, the most efficient way of communicating to a server on the same machine will be used.
displaynumber(显示号)
The phrase "display" is usually used to refer to collection of monitors that share a common keyboard and pointer (mouse, tablet, etc.). Most workstations tend to only have one keyboard, and therefore, only one display. Larger, multi-user systems, however, frequently have several displays so that more than one person can be doing graphics work at once. To avoid confusion, each display on a machine is assigned a display number (beginning at 0) when the X server for that display is started. The display number must always be given in a display name.
screennumber
Some displays share a single keyboard and pointer among two or more monitors. Since each monitor has its own set of windows, each screen is assigned a screen number (beginning at 0) when the X server for that display is started. If the screen number is not given, screen 0 will be used.

On POSIX systems, the default display name is stored in your DISPLAY environment variable. This variable is set automatically by the xterm terminal emulator. However, when you log into another machine on a network, you will need to set DISPLAY by hand to point to your display. For example,


    % setenv DISPLAY myws:0
    $ DISPLAY=myws:0; export DISPLAY
The xon script can be used to start an X program on a remote machine; it automatically sets the DISPLAY variable correctly.

Finally, most X programs accept a command line option of -display displayname to temporarily override the contents of DISPLAY. This is most commonly used to pop windows on another person's screen or as part of a "remote shell" command to start an xterm pointing back to your display. For example,


    % xeyes -display joesws:0 -geometry 1000x1000+0+0
    % rsh big xterm -display myws:0 -ls </dev/null &

X servers listen for connections on a variety of different communications channels (network byte streams, shared memory, etc.). Since there can be more than one way of contacting a given server, The hostname part of the display name is used to determine the type of channel (also called a transport layer) to be used. X servers generally support the following types of connections:

local

The hostname part of the display name should be the empty string. For example: :0, :1, and :0.1. The most efficient local transport will be chosen.
TCP/IP

The hostname part of the display name should be the server machine's IP address name. Full Internet names, abbreviated names, and IP addresses are all allowed. For example: x.org:0, expo:0, 198.112.45.11:0, bigmachine:1, and hydra:0.1.
DECnet

The hostname part of the display name should be the server machine's nodename, followed by two colons instead of one. For example: myws::0, big::1, and hydra::0.1

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值