Originally Posted by shivaa
In that case, you can set DISPLAY manually as,
For bash shell:
[user@localhost]~$ set DISPLAY=localhost:0.0; export DISPLAY
For csh/tcsh shell:
[user@localhost]~$ setenv DISPLAY localhost:0.0
To check whether DISPLAY is set properly, invoke any x
[user@localhost]~$ xterm &
[user@localhost]~$ xclock &
If these x
utilities launch on your display, then DISPLAY variable is set properly. You can then launch any other utilities you want.
1. the X server didn't start, and until it does you have no idea what the display environment variable SHOULD be, as noted in the reference you gave.
2. using "localhost:0.0" directs applications to use TCP, port 6000. By default TCP is NOT enabled, even when the X server does start, so applications will still fail, but with a "Error: Can't open display: localhost:0.0".
There are other possible reasons for X to be unable to create the lock or socket.
The access mode for /tmp should/must be rwxrwxrwt (the t is as important as the rwx - it is what provides the protection to the socket). SELinux (if active) also requires /tmp to have the proper security labeling: system_u
Repairing SELinux labeling can be done with a "restorecon -R /tmp", but access mode requires a "chmod a=rwxt /tmp".
When X gets starts, it will create a /tmp/.X11-unix directory for the purpose of holding the name for the domain socket it uses for communication. In normal operation (assuming only one connection) there is also a /tmp/.X0-lock file to prevent duplication (and hijacking) of a display. The "0" is the display number (the part of the DISPLAY environment value which is formatted "server:display.screen", the 'server' is only used for TCP values, and may have the name "unix" as a designation for a domain socket, the 'screen' is to support a multi monitor environment).
If SELinux is active, then the label given the /tmp/.X11-unix directiry is "system_u
bject_r:xdm_tmp_t:s0", and the access mode is also rwxrwxrwt. And any lock files will be "system_u
bject_r:xdm_tmp_t:s0". Ownership of any lock files and the directory is root, with group root.
Within the directory /tmp/.X11-unix directory will be a file "X0", which corresponds to the lock file /tmp/X0-lock. When multiple displays are active there will be one for each display. When a display is inactive (as in no X server active), there would normally be no file present. The SELinux label of a file should be "system_u
bject_r:xdm_tmp_t:s0", with access mode rwxrwxrwx. Security control over accesses are done via the X servers authorization keys which are put in other places.
If /tmp appears correct, and there is NO X server active (such as booting into runlevel 3 for instance) then it is entirely valid to delete "/tmp/.X*-lock" files and the directory tree "/tmp/.X11-unix". As they should/will be recreated as needed.
If you like, you can record an entire trace of activity by first using the "script" utility to create a log. The only entries in the log file will be those used in the terminal where the script command is started. It will record any error messages, commands, and output generated. It will NOT record any activity done by the X server (other than error messages) or utilities started when using the X environment. The log is only terminated when you exit the script utility.