When I run vncserver command it will create session with display as :1 ,and in the terminal when we check the display variable, it is set as DISPLAY=:1, Is it possible to create a vnc session with display variable set as DISPLAY=hostname:1, I know to change the display variable by using export or setenv command depending on the shell, But if I change the display variable manually to hostname:1 , xhost command doesn't work as the vnc session is originally created for :1 only,
Am not sure why this behavior or is this the default behavior?
Am using Solaris 11.4 OS
You're misunderstanding how X Windows
DISPLAYenvironment variables work.Per the X.org documentation (bolding mine):
From the X server process, there is no
hostnamepart of a display name - the server is running on the system it's running on.So setting an X server to run on
hostname:1is no different than setting it to run on:1.For X Windows client programs, though, the
hostnamepart of aDISPLAYenvironment variable denotes the system where the display they need to connect to is running. In other words, the connect becomes a network connection.When your
xtermprocess is started locally, it connects to the local X server process by default, denoted with:1(or:0or:0.0or:2.0...). SettingDISPLAY=hostname:1means the X client process will try to perform a network connection to the:1display, running on thehostnamesystem. And if the X server process isn't configured to listen for network connections in addition to local connections, or if there's a firewall in the way, that client process will fail to connect tohostname:1.So just using the
xhostcommand to enable remote access won't work if the X server isn't configure to allow such access.For the
:1display, if your X server is configured to allow remote access, runningnetstat -an | grep 6001will produce output something like this:If you do not see any process with
LISTENon port 6001, the X server for your:1display is not configured to accept remote connections.