Why I can't use 'startx' command to start X Server on RHEL7 with "X window system" package group?
Environment
- Red Hat Enterprise Linux 7
- xorg-x11-xinit-1.3.2-14.el7.x86_64
Issue
-
Can't start the X server using the
startxcommand, while the basicxinitcommand works. -
The server is running RHEL7, installed as a minimal server, only the core and "X window system" package group plus
xtermare installed. But when try to runstartxcommand, it fails with following error:xinit: connection to X server lost waiting for X server to shut down (EE) Server terminated successfully (0). Closing log file. -
xinitcommand without any options starts fine, butstartxwith the default RHEL7 systemxinitrcscript fails. What is causing this problem?
Resolution
Note: This solution only applies if you are intending to use 'twm' or 'mwm' graphical environments. For questions regarding installing a full-feature GUI, such as Gnome, please see How to install a graphical user interface (GUI) for Red Hat Enterprise Linux
-
Install "motif" package on system and replace
/usr/bin/twmwith/usr/bin/mwmin/etc/X11/xinit/xinitrcand/etc/X11/xinit/Xclientsboth files.
Eg: -
The
/etc/X11/xinit/xinitrcfile after replacing/usr/bin/twmwith/usr/bin/mwmshould have following entry:<snip> if [ -f $HOME/.Xclients ]; then exec $CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients || \ exec $CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients elif [ -f /etc/X11/xinit/Xclients ]; then exec $CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients || \ exec $CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients else # Failsafe settings. Although we should never get here # (we provide fallbacks in Xclients as well) it can't hurt. [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45' [ -x /usr/bin/xclock ] && /usr/bin/xclock -geometry 100x100-5+5 & [ -x /usr/bin/xterm ] && xterm -geometry 80x50-50+150 & [ -x /usr/bin/mwm ] && /usr/bin/mwm fi </snip> -
The
/etc/X11/xinit/Xclientsscript file after replacing/usr/bin/twmwith/usr/bin/mwmshould have following entry:<snip> # Failsafe. # these files are left sitting around by TheNextLevel. rm -f $HOME/Xrootenv.0 # Argh! Nothing good is installed. Fall back to twm { # gosh, neither fvwm95 nor fvwm2 is available; # fall back to failsafe settings [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45' if [ -x /usr/bin/xclock ] ; then /usr/bin/xclock -geometry 100x100-5+5 & fi if [ -x /usr/bin/xterm ] ; then /usr/bin/xterm -geometry 80x50-50+150 & fi if [ -x /usr/bin/firefox -a -f /usr/share/doc/HTML/index.html ]; then /usr/bin/firefox /usr/share/doc/HTML/index.html & fi if [ -x /usr/bin/mwm ] ; then exec /usr/bin/mwm fi } </snip> -
After above changes try to run
startxcommand.
Root Cause
-
The
startxscript is a front end toxinit. To determine the client to run,startxfirst looks for a file called.xinitrcin the user's home directory. If that is not found, it uses the filexinitrcin the xinit library directory(/etc/X11/xinit/). The/etc/X11/xinit/xinitrcfile have following entry:<snip> if [ -f $HOME/.Xclients ]; then exec $CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients || \ exec $CK_XINIT_SESSION $SSH_AGENT $HOME/.Xclients elif [ -f /etc/X11/xinit/Xclients ]; then exec $CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients || \ exec $CK_XINIT_SESSION $SSH_AGENT /etc/X11/xinit/Xclients else # Failsafe settings. Although we should never get here # (we provide fallbacks in Xclients as well) it can't hurt. [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45' [ -x /usr/bin/xclock ] && /usr/bin/xclock -geometry 100x100-5+5 & [ -x /usr/bin/xterm ] && xterm -geometry 80x50-50+150 & [ -x /usr/bin/twm ] && /usr/bin/twm fi </snip>
In above output we can see that
/etc/X11/xinit/Xclientsscript is being called.
-
The
/etc/X11/xinit/Xclientsscript have following entry:<snip> # Failsafe. # these files are left sitting around by TheNextLevel. rm -f $HOME/Xrootenv.0 # Argh! Nothing good is installed. Fall back to twm { # gosh, neither fvwm95 nor fvwm2 is available; # fall back to failsafe settings [ -x /usr/bin/xsetroot ] && /usr/bin/xsetroot -solid '#222E45' if [ -x /usr/bin/xclock ] ; then /usr/bin/xclock -geometry 100x100-5+5 & fi if [ -x /usr/bin/xterm ] ; then /usr/bin/xterm -geometry 80x50-50+150 & fi if [ -x /usr/bin/firefox -a -f /usr/share/doc/HTML/index.html ]; then /usr/bin/firefox /usr/share/doc/HTML/index.html & fi if [ -x /usr/bin/twm ] ; then exec /usr/bin/twm fi } </snip> -
The above scripts have entry for
/usr/bin/twm, which is deprecated in RHEL7. There is no package which provides this binary in RHEL7.
This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.