如何指定显示?

时间:2021-01-22 21:24:00

When I run some programs over SSH, such as firefox &, I get an error

当我在SSH上运行一些程序(如firefox &)时,会出现错误

Error: no display specified 

I would like to open many displays, still showing the stdout of each program.

我想打开许多显示器,仍然显示每个程序的标准输出。

Initial Question: How can I specify the display to get a many-displayed program?

最初的问题:我如何指定显示以得到一个多显示程序?

Pablo Santa Cruz gives me the following code as a solution. I do not understand it.

Pablo Santa Cruz提供了以下代码作为解决方案。我不明白。

$ export DISPLAY=yourmachine.yourdomain.com:0.0

$ firefox &

What are yourmachine and yourdomain.com in the command?

命令中有什么是你的机器和你的域名。com ?

11 个解决方案

#1


58  

The way that X works is the same as the way any network program works. You have a server of some description (in this case, the X display server) which runs on a specific machine, and you have X clients (like firefox) that try to connect to that server to get their information displayed.

X的工作方式与任何网络程序的工作方式相同。您有一个在特定机器上运行的描述服务器(在本例中是X display server),并且您有X客户端(如firefox)试图连接到该服务器以显示其信息。

Often (on "home" machines), the client and server run on the same box and there's only one server, but X is powerful enough that this doesn't need to happen. It was built with the server/client separation built in from the start.

通常(在“home”机器上),客户端和服务器运行在同一个盒子上,只有一个服务器,但是X足够强大,不需要这样做。它是使用从一开始就内置的服务器/客户端分离构建的。

This allows you to do such wondrous things such as log on to your box (in text mode) halfway around the planet, tell it that the display server is the box you're currently on and, voila, the windows suddenly start appearing locally.

这让你可以做一些奇妙的事情,比如在地球的另一端登录你的框(以文本模式),告诉它显示服务器是你当前所在的框,然后,瞧,窗口突然开始本地显示。

In order for a client to interact with a user, it needs to know how to find the server. There are a number of ways to do this. Many clients allow the -display or --displayoption to specify it:

为了让客户端与用户交互,它需要知道如何查找服务器。有很多方法可以做到这一点。许多客户端允许-display或-displayoption指定它:

xeyes -display paxbox1.paxco.com:0.0

Many will use the DISPLAY environment variable if a display isn't specifically given. You can set this variable like any other:

如果没有指定显示,许多人将使用DISPLAY环境变量。你可以像其他变量一样设置这个变量:

DISPLAY=paxbox1.paxco.com:0.0; export DISPLAY # in .profile
export DISPLAY=paxbox1.paxco.com:0.0 # in your shell
DISPLAY=paxbox1.paxco.com:0.0 firefox & # for that command (shell permitting)

The first part of the DISPLAY variable is just the address of the display server machine. It follows the same rule as any other IP address; it can be a resolvable DNS name (including localhost) or a specific IP address (such as 192.168.10.55).

显示变量的第一部分仅仅是显示服务器的地址。它遵循与任何其他IP地址相同的规则;它可以是可解析的DNS名称(包括localhost)或特定的IP地址(如192.168.10.55)。

The second part is X-specific. It gives the X "display" (X server) number and screen number to use. The first (display number) generally refers to a group of devices containing one or more screens but with a single keyboard and mouse (i.e., one input stream). The screen number generally gives the specific screen within that group.

第二部分是X-specific。它给出要使用的X“display”(X server)号和屏幕号。第一个(显示号)通常指包含一个或多个屏幕但只有一个键盘和鼠标的一组设备。,一个输入流)。屏幕编号通常给出该组中的特定屏幕。

An example would be:

一个例子是:

+----------------------------------------+
|paxbox1.paxco.com|                      |
+-----------------+                      |
|                                        |
|  +----------+----+  +----------+----+  |
|  |Display :0|    |  |Display :1|    |  |
|  +----------+    |  +----------+    |  |
|  |               |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.0| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.1| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.2| |  | |Screen :1.0| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.3| |  | |Screen :1.1| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | | Keyboard  | |  | |  Keyboard | |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |   Mouse   | |  | |   Mouse   | |  |
|  | +-----------+ |  | +-----------+ |  |
|  +---------------+  +---------------+  |
|                                        |
+----------------------------------------+

Here you have a single machine (paxbox1.paxco.com) with two display servers. The first has four screens and the second has two. The possibilities are then:

这里有一台机器(paxbox1.paxco.com)和两个显示服务器。第一个有四个屏幕,第二个有两个。可能性是:

DISPLAY=paxbox1.paxco.com:0.0
DISPLAY=paxbox1.paxco.com:0.1
DISPLAY=paxbox1.paxco.com:0.2
DISPLAY=paxbox1.paxco.com:0.3
DISPLAY=paxbox1.paxco.com:1.0
DISPLAY=paxbox1.paxco.com:1.1

depending on where you want your actual windows to appear and which input devices you want to use.

这取决于您希望实际窗口出现的位置和您希望使用的输入设备。

#2


15  

$ export DISPLAY=yourmachine.yourdomain.com:0.0
$ firefox &

#3


11  

When you are connecting to another machine over SSH, you can enable X-Forwarding in SSH, so that X windows are forwarded encrypted through the SSH tunnel back to your machine. You can enable X forwarding by appending -X to the ssh command line or setting ForwardX11 yes in your SSH config file.

当您通过SSH连接到另一台机器时,您可以在SSH中启用X-转发,以便通过SSH通道将X窗口转发到您的计算机。您可以通过向ssh命令行添加-X或在ssh配置文件中设置forward dx11 yes来启用X转发。

To check if the X-Forwarding was set up successfully (the server might not allow it), just try if echo $DISPLAY outputs something like localhost:10.0.

要检查X-Forwarding是否设置成功(服务器可能不允许),请尝试一下echo $DISPLAY输出,比如localhost:10.0。

#4


8  

Try

试一试

export DISPLAY=localhost:0.0

#5


6  

Try installing the xorg-x11-xauth package.

尝试安装xorg-x11-xauth包。

#6


4  

I ran into a similar issue, so maybe this answer will help someone.

我遇到了一个类似的问题,所以也许这个答案可以帮助别人。

The reason for the Error: no display specified error is that Firefox is being launched, but there is no X server (GUI) running on the remote host. You can use X11 forwarding to run Firefox on the remote host, but display it on your local host. On Mac OS X, you will need to download XQuartz in order to use X11 forwarding. Without it, you won't have a $DISPLAY variable set, so if you try and echo $DISPLAY, it will be blank.

错误的原因是:没有显示指定的错误是因为Firefox正在启动,但是在远程主机上没有运行X服务器(GUI)。可以使用X11转发在远程主机上运行Firefox,但在本地主机上显示它。在Mac OS X上,需要下载XQuartz才能使用X11转发。如果没有它,就不会有$DISPLAY变量集,因此如果尝试回显$DISPLAY,它将是空的。

#7


2  

I faced similar problem today. So, here's a simple solution: While doing SSH to the machine, just add Ctrl - Y.

我今天遇到了类似的问题。这里有一个简单的解决方案:在对机器执行SSH时,只需添加Ctrl - Y。

ssh user@ip_address -Y

After login, type firefox &. And you are good to go.

登录后,输入firefox &。你可以走了。

#8


1  

Even i faced the same in CentOS 6.8.

就连我在CentOS 6.8也面临同样的问题。

yum reinstall xorg*

End your current session and open another session in tool like mobiXterm. Make sure session has X11 forwarding enabled in the tool.

结束当前会话并使用mobiXterm之类的工具打开另一个会话。确保会话在工具中启用了X11转发。

#9


1  

Please do NOT try to set $DISPLAY manually when connecting over SSH.
If you connect via SSH -X and $DISPLAY stays empty, this usually means that no encrypted channel could be established.

在通过SSH连接时,请不要尝试手动设置$DISPLAY。如果通过SSH -X连接,并且$DISPLAY保持为空,这通常意味着无法建立加密通道。

Most likely you are missing the package xauth or xorg-x11-xauth. Try to install it on the remote machine using:

很有可能您丢失了xauth或xorg-x11-xauth包。尝试在远程机器上安装它:

sudo apt-get install xauth

or

sudo apt-get install xorg-x11-xauth

After that end and restart your SSH connection. Don't forget to use SSH -X so that X Window output is forwarded to your local machine.

结束后,重新启动SSH连接。不要忘记使用SSH -X,以便将X窗口输出转发到本地计算机。

Now try echo $DISPLAYagain to see if $DISPLAY has been set automatically by the SSH demon. It should show you a line with an IP address and a port.

现在再试一次echo $DISPLAYagain,看看SSH恶魔是否自动设置了$DISPLAY。它应该显示一个具有IP地址和一个端口的行。

#10


1  

login to your server via

登录到您的服务器通过。

ssh -X root@yourIP

edit /etc/ssh/sshd_config file, and add this line to it.

编辑/etc/ sshd_config文件,并添加这一行。

X11UseLocalhost no

Restart sshd. for CentOS (check your distribution)

重新启动sshd。CentOS(检查你的分配)

/sbin/service sshd restart

check your DISPLAY

检查你的显示

echo $DISPLAY

you should see this

您应该看到这

yourIP:10.0

Enjoy

享受

firefox

for more info

更多信息

#11


0  

I through vnc to understand the X11 more. To specify the display to get a many-displayed program, export DISPLAY=IP:DisplayNum.ScreenNum

我通过vnc了解了X11。要指定要获取多显示程序的显示,导出display =IP:DisplayNum.ScreenNum

For example,

例如,

vncserver :2
vncserver -list
echo '$DISPLAY'=$DISPLAY 
export DISPLAY=:2  # export DISPLAY=IP:DisplayNum or export DISPLAY=:DisplayNum for localhost; So that can vnc connect and see the vnc desktop :2 if $DISPLAY is not :2.
echo '$DISPLAY'=$DISPLAY

#1


58  

The way that X works is the same as the way any network program works. You have a server of some description (in this case, the X display server) which runs on a specific machine, and you have X clients (like firefox) that try to connect to that server to get their information displayed.

X的工作方式与任何网络程序的工作方式相同。您有一个在特定机器上运行的描述服务器(在本例中是X display server),并且您有X客户端(如firefox)试图连接到该服务器以显示其信息。

Often (on "home" machines), the client and server run on the same box and there's only one server, but X is powerful enough that this doesn't need to happen. It was built with the server/client separation built in from the start.

通常(在“home”机器上),客户端和服务器运行在同一个盒子上,只有一个服务器,但是X足够强大,不需要这样做。它是使用从一开始就内置的服务器/客户端分离构建的。

This allows you to do such wondrous things such as log on to your box (in text mode) halfway around the planet, tell it that the display server is the box you're currently on and, voila, the windows suddenly start appearing locally.

这让你可以做一些奇妙的事情,比如在地球的另一端登录你的框(以文本模式),告诉它显示服务器是你当前所在的框,然后,瞧,窗口突然开始本地显示。

In order for a client to interact with a user, it needs to know how to find the server. There are a number of ways to do this. Many clients allow the -display or --displayoption to specify it:

为了让客户端与用户交互,它需要知道如何查找服务器。有很多方法可以做到这一点。许多客户端允许-display或-displayoption指定它:

xeyes -display paxbox1.paxco.com:0.0

Many will use the DISPLAY environment variable if a display isn't specifically given. You can set this variable like any other:

如果没有指定显示,许多人将使用DISPLAY环境变量。你可以像其他变量一样设置这个变量:

DISPLAY=paxbox1.paxco.com:0.0; export DISPLAY # in .profile
export DISPLAY=paxbox1.paxco.com:0.0 # in your shell
DISPLAY=paxbox1.paxco.com:0.0 firefox & # for that command (shell permitting)

The first part of the DISPLAY variable is just the address of the display server machine. It follows the same rule as any other IP address; it can be a resolvable DNS name (including localhost) or a specific IP address (such as 192.168.10.55).

显示变量的第一部分仅仅是显示服务器的地址。它遵循与任何其他IP地址相同的规则;它可以是可解析的DNS名称(包括localhost)或特定的IP地址(如192.168.10.55)。

The second part is X-specific. It gives the X "display" (X server) number and screen number to use. The first (display number) generally refers to a group of devices containing one or more screens but with a single keyboard and mouse (i.e., one input stream). The screen number generally gives the specific screen within that group.

第二部分是X-specific。它给出要使用的X“display”(X server)号和屏幕号。第一个(显示号)通常指包含一个或多个屏幕但只有一个键盘和鼠标的一组设备。,一个输入流)。屏幕编号通常给出该组中的特定屏幕。

An example would be:

一个例子是:

+----------------------------------------+
|paxbox1.paxco.com|                      |
+-----------------+                      |
|                                        |
|  +----------+----+  +----------+----+  |
|  |Display :0|    |  |Display :1|    |  |
|  +----------+    |  +----------+    |  |
|  |               |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.0| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  |               |  |
|  | |Screen :0.1| |  |               |  |
|  | +-----------+ |  |               |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.2| |  | |Screen :1.0| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |Screen :0.3| |  | |Screen :1.1| |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | | Keyboard  | |  | |  Keyboard | |  |
|  | +-----------+ |  | +-----------+ |  |
|  | +-----------+ |  | +-----------+ |  |
|  | |   Mouse   | |  | |   Mouse   | |  |
|  | +-----------+ |  | +-----------+ |  |
|  +---------------+  +---------------+  |
|                                        |
+----------------------------------------+

Here you have a single machine (paxbox1.paxco.com) with two display servers. The first has four screens and the second has two. The possibilities are then:

这里有一台机器(paxbox1.paxco.com)和两个显示服务器。第一个有四个屏幕,第二个有两个。可能性是:

DISPLAY=paxbox1.paxco.com:0.0
DISPLAY=paxbox1.paxco.com:0.1
DISPLAY=paxbox1.paxco.com:0.2
DISPLAY=paxbox1.paxco.com:0.3
DISPLAY=paxbox1.paxco.com:1.0
DISPLAY=paxbox1.paxco.com:1.1

depending on where you want your actual windows to appear and which input devices you want to use.

这取决于您希望实际窗口出现的位置和您希望使用的输入设备。

#2


15  

$ export DISPLAY=yourmachine.yourdomain.com:0.0
$ firefox &

#3


11  

When you are connecting to another machine over SSH, you can enable X-Forwarding in SSH, so that X windows are forwarded encrypted through the SSH tunnel back to your machine. You can enable X forwarding by appending -X to the ssh command line or setting ForwardX11 yes in your SSH config file.

当您通过SSH连接到另一台机器时,您可以在SSH中启用X-转发,以便通过SSH通道将X窗口转发到您的计算机。您可以通过向ssh命令行添加-X或在ssh配置文件中设置forward dx11 yes来启用X转发。

To check if the X-Forwarding was set up successfully (the server might not allow it), just try if echo $DISPLAY outputs something like localhost:10.0.

要检查X-Forwarding是否设置成功(服务器可能不允许),请尝试一下echo $DISPLAY输出,比如localhost:10.0。

#4


8  

Try

试一试

export DISPLAY=localhost:0.0

#5


6  

Try installing the xorg-x11-xauth package.

尝试安装xorg-x11-xauth包。

#6


4  

I ran into a similar issue, so maybe this answer will help someone.

我遇到了一个类似的问题,所以也许这个答案可以帮助别人。

The reason for the Error: no display specified error is that Firefox is being launched, but there is no X server (GUI) running on the remote host. You can use X11 forwarding to run Firefox on the remote host, but display it on your local host. On Mac OS X, you will need to download XQuartz in order to use X11 forwarding. Without it, you won't have a $DISPLAY variable set, so if you try and echo $DISPLAY, it will be blank.

错误的原因是:没有显示指定的错误是因为Firefox正在启动,但是在远程主机上没有运行X服务器(GUI)。可以使用X11转发在远程主机上运行Firefox,但在本地主机上显示它。在Mac OS X上,需要下载XQuartz才能使用X11转发。如果没有它,就不会有$DISPLAY变量集,因此如果尝试回显$DISPLAY,它将是空的。

#7


2  

I faced similar problem today. So, here's a simple solution: While doing SSH to the machine, just add Ctrl - Y.

我今天遇到了类似的问题。这里有一个简单的解决方案:在对机器执行SSH时,只需添加Ctrl - Y。

ssh user@ip_address -Y

After login, type firefox &. And you are good to go.

登录后,输入firefox &。你可以走了。

#8


1  

Even i faced the same in CentOS 6.8.

就连我在CentOS 6.8也面临同样的问题。

yum reinstall xorg*

End your current session and open another session in tool like mobiXterm. Make sure session has X11 forwarding enabled in the tool.

结束当前会话并使用mobiXterm之类的工具打开另一个会话。确保会话在工具中启用了X11转发。

#9


1  

Please do NOT try to set $DISPLAY manually when connecting over SSH.
If you connect via SSH -X and $DISPLAY stays empty, this usually means that no encrypted channel could be established.

在通过SSH连接时,请不要尝试手动设置$DISPLAY。如果通过SSH -X连接,并且$DISPLAY保持为空,这通常意味着无法建立加密通道。

Most likely you are missing the package xauth or xorg-x11-xauth. Try to install it on the remote machine using:

很有可能您丢失了xauth或xorg-x11-xauth包。尝试在远程机器上安装它:

sudo apt-get install xauth

or

sudo apt-get install xorg-x11-xauth

After that end and restart your SSH connection. Don't forget to use SSH -X so that X Window output is forwarded to your local machine.

结束后,重新启动SSH连接。不要忘记使用SSH -X,以便将X窗口输出转发到本地计算机。

Now try echo $DISPLAYagain to see if $DISPLAY has been set automatically by the SSH demon. It should show you a line with an IP address and a port.

现在再试一次echo $DISPLAYagain,看看SSH恶魔是否自动设置了$DISPLAY。它应该显示一个具有IP地址和一个端口的行。

#10


1  

login to your server via

登录到您的服务器通过。

ssh -X root@yourIP

edit /etc/ssh/sshd_config file, and add this line to it.

编辑/etc/ sshd_config文件,并添加这一行。

X11UseLocalhost no

Restart sshd. for CentOS (check your distribution)

重新启动sshd。CentOS(检查你的分配)

/sbin/service sshd restart

check your DISPLAY

检查你的显示

echo $DISPLAY

you should see this

您应该看到这

yourIP:10.0

Enjoy

享受

firefox

for more info

更多信息

#11


0  

I through vnc to understand the X11 more. To specify the display to get a many-displayed program, export DISPLAY=IP:DisplayNum.ScreenNum

我通过vnc了解了X11。要指定要获取多显示程序的显示,导出display =IP:DisplayNum.ScreenNum

For example,

例如,

vncserver :2
vncserver -list
echo '$DISPLAY'=$DISPLAY 
export DISPLAY=:2  # export DISPLAY=IP:DisplayNum or export DISPLAY=:DisplayNum for localhost; So that can vnc connect and see the vnc desktop :2 if $DISPLAY is not :2.
echo '$DISPLAY'=$DISPLAY