I'm experiencing inconsistent $DISPLAY variables on my OEL6 servers which have caused quite a bit of trouble with socket files.I have found surprisingly little on what actually sets the environment variable $DISPLAY, I know what it does(more-or-less) and how to manually set it in the shell, What I don't know is HOW it is set when the system is starting. so  How and Where is the GDM environment variable $DISPLAY set and how can I force GDM to :0.0? Note: I am NOT looking for export DISPLAY=:0.0 as that will not be of any use in this case.
RHEL6 && OEL6 How is $DISPLAY determined on startup?
rhel;x11;gnome;gdm;oracle linux
In man X(7) there is section Display Names which states:On POSIX systems, the default display name is stored in your DISPLAY environment variable. This variable is set automatically by the xterm terminal emulator.and next:Finally, most X programs accept a command line option of -display displayname to temporarily override the contents of DISPLAY. This is most commonly used to pop windows on another person's screen or as part of a remote shell command to start an xterm pointing back to your display.man for Xserver(1) we have information about Options::displaynumber  The X server runs as the given displaynumber, which by default is 0. If multiple X servers are to run simultaneously on a host, each must have a unique display number. See the DISPLAY NAMES section of the X(7) manual page to learn how to specify which display number clients should try to use.Take a look at: /etc/gdm/Init/Default (available on ArchLinux, so not sure if in RHEL syststem it is available).Some more findings. DISPLAY is set by xinit program. xinit.c has this:if (argc > 0 && (argv[0][0] == ':' && isdigit(argv[0][1])))    displayNum = *argv;else    displayNum = *sptr++ = default_display;(...)static voidset_environment(void){    if (setenv(DISPLAY, displayNum, TRUE) == -1)        Fatal(unable to set DISPLAY);}So xinit can set default value or take it from option passed to xinit when it was run. xinit(1):       xinit [ [ client ] options ... ] [ -- [ server ] [ display ] options ... ]And one more. environment variable can be set by PAM. Eg. /etc/security/pam_env.conf# Set the DISPLAY variable if it seems reasonable#DISPLAY                DEFAULT=${REMOTEHOST}:0.0 OVERRIDE=${DISPLAY}