Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What if there is a Can't open display error when linux runs the x program?

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Editor to share with you how to run linux x program Can't open display error, I believe that most people do not understand, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

On Linux/Unix operating systems, DISPLAY is used to set where graphics are displayed. After logging in to the graphical interface or the command line interface directly, use startx to start the graphics, and the DISPLAY environment variable will be automatically set to: 0:0. At this time, you can open the terminal and output the name of the graphics program (such as xclock) to start the program. The graphics will be displayed on the local window. Enter printenv on the terminal to view the current environment variables, and the output results are as follows:

DISPLAY=:0.0

Use xdpyinfo to view more detailed information currently displayed.

The format of DISPLAY environment variable is host:NumA.NumB. Host refers to the host name or ip address where Xserver is located. The graph will be displayed on this machine. It can be a Linux/Unix machine with a graphical interface started, or a Windows machine with Xserver installed on Windows platforms such as Exceed, X-Deep/32 and so on. If Host is empty, it means that Xserver is running locally and the graphics program (Xclient) connects to Xserver using unix socket instead of TCP. When connecting using TCP, NumA subtracts 6000 from the connected port. If NumA is 0, it means connecting to port 6000. When connecting using unix socket, it indicates the path of the connected unix socket. If 0, it means connecting to / tmp/.X11-unix/X0. NumB is almost always 0. 5%.

If you use su username or su-username to switch to another user and use the command

Export DISPLAY=:0.0

# # (this sentence can be written into .bashrc)

When you set the DISPLAY environment variable, you will receive the following error when you run a graphics program such as xclock:

Xlib: connection to ": 0.0" refused by server

Xlib: No protocol specified

Error: Can't open display:: 0.0

This is because Xserver does not allow graphics from other users' graphics programs to be displayed on the current screen by default. If you need the graphics of another user to be displayed on the current screen, you should execute the following command with the currently logged-in user, that is, the user before the identity switch

Xhost +

You need sux. Su won't bring this x environment.

Did you log in as a root user? If so, delete / root/.Xauthority, logout, and try again.

_ X11TransSocketINETConnect () can't get address for localhost:6001: Name > > or service not known Error: Can't open display: localhost:1.0

Solution:

1. See if there is 127.0.0.1 localhost.localdomain localhost in / etc/hosts. If not, then

Configure Hostnam

Edit the configuration file:

/ etc/hosts

127.0.0.1 localhost localhost.localdomain localhost

10.10.11.16 uatdb.aeonlife.cn uatdb

Where 10.10.11.16 is the local address and uatdb host name

2. Log in with Oracle user and set DISPLAY environment variable

Export DISPLAY=your_IPaddress:0.0

Note: your _ IPaddress is the IP address of machine A

Step 1: log in to linux with root and start the vnc service

Step 2: according to the port of vnc, set export DISPLAY=localhost:1 (1 means that vnc starts on the first tty). The startup information of vnc is shown in Annex 1.

Step 3: execute xhost + and prompt "access control disabled, clients can connect from any host" to be correct.

The operation log under linux is as follows:

[root@localhost ~] # vncserver

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

Starting applications specified in / root/.vnc/xstartup

Log file is / root/.vnc/localhost:1.log

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

[root@localhost ~] # xhost +

Access control disabled, clients can connect from any host

There is a problem with unable when setting up xhost.

The above is all the contents of the article "what to do if there is a Can't open display error in the linux x program?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report