linux解决xhost: unable to open display ""

Set up xhost method steps under Linux

The first step: log in to linux with root and start the vnc service;

root@gao-virtual-machine:~# vncserver
did not find the 'vncserver' command, what do you want to enter:
command 'vnc4server' from package 'vnc4server' (universe)

After execution, re-execute the vnc4server command according to the above prompts

hint:

The program "vnc4server" has not been installed. You can install it with:
apt-get install vnc4server

Then execute the apt-get install vnc4server command to install, and after the installation is complete, re-execute vnc4server

Step 2: According to the port of vnc, set export DISPLAY=localhost:1 (1 means vnc is started on the first tty), see appendix 1 for the start-up information of vnc;

Step 3: Execute xhost +, and the prompt "access control disabled, clients can connect from any host" is correct.

The operation log under linux is as follows:

root@gao-virtual-machine:~# vnc4server

root@gao-virtual-machine:~# apt-get install vnc4server The
program "vnc4server" has not been installed. You can install it with:
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 

When setting up xhost, the problem of disable occurred. Use the appeal method to get it done.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325012075&siteId=291194637