106 Chapter 7. X Servers and Clients
you must already be logged into the system at runlevel 3 to be able to type commands, startx is only
designed to bring up certain X clients, such as a desktop environment, in a particular manner. It does
not provide any user authentication.
When startx begins, it looks for a .xinitrc file in the user’s home directory to define the X clients
to run. If it does not find that file present, it will run the system default /etc/X11/xinit/xinitrc
script instead. The startx script then does the same thing with the .xserverrc file, looking for
it in the user’s home directory and then running the default /etc/X11/xinit/xserverrc script if
it cannot be found. Since many different X clients exist, the xinitrc files are very important. The
xserverrc script is less important. It only sets the X server to connect to the X clients. Since the
default X server is already configured with the /etc/X11/X link, Red Hat Linux does not install a
default xserverrc.
The default xinitrc script then looks for user-defined files and default system files, including .Xre-
sources, .Xmodmap, and .Xkbmap in the user’s home directory and Xresources, Xmodmap, and
Xkbmap in the /etc/X11/ directory. The Xmodmap and Xkbmap files, if they exist, are used by the
xmodmap utility to configure the keyboard. The Xresources files are read to assign specific prefer-
ence values to particular applications.
After setting these options, the xinitrc script executes all scripts located in the
/etc/X11/xinit/xinitrc.d/ directory. One important script in this directory is xinput, which
configures settings such as the default language to use and the desktop environment to start from
(/etc/sysconfig/desktop).
Next, the xinitrc script tries to execute .Xclients in the user’s home directory and turns to
/etc/X11/xinit/Xclients if it cannot be found. The purpose of the Xclients file is to start the
desktop environment or, possibly, just a basic window manager. The .Xclients script in the
user’s home directory starts the user-specified desktop environment or window manager in the
.Xclients-default file. If .Xclients does not exist in the user’s home directory, the standard
/etc/X11/init/Xclients script attempts to start another desktop environment, trying GNOME
first and then KDE. If a desktop environment cannot be found by this point, Xclients attempts the
default window manager listed in the .wm_style file in the user’s home directory. If this fails, it
cycles through a predefined list of window managers.
The preferred X client applications should now have started by this point, along with the XFree86
server. If you need more details concerning starting X in runlevel 3, refer to the startx and xinit
man pages and read through the scripts named above.
7.4.2. Runlevel 5: prefdm
Runlevel 5 uses a slightly different method to start X. When the system starts, no one is logged into
the system by default. In order for a user to start a session, they must log in to the system. In runlevel
5, users authenticating themselves at the console use a display manager, a special X client that allows
the user to submit their login name and password.
Depending on the desktop environments installed on your specific Red Hat Linux system, three dif-
ferent display managers are available to handle the user authentication. The xdm display manager is
the original X authentication tool. xdm only allows you to log in and start an X session, nothing more.
The gdm display manager, designed to work with the GNOME desktop environment, and kdm display
manager, used with the KDE desktop environment, allow you to set the desktop environment, or ses-
sion, you would like to use after authentication. Additionally, you can restart or halt the system from
the login screen. The gdm display manager also allows you to configure the language you would like
to use.
When the system enters runlevel 5, a line in the /etc/inittab file specifies that the prefdm script is
executed in order to determine the preferred display manager to bring up for user authentication. The
prefdm script uses the preferences stated in the /etc/sysconfig/desktop file to find the proper
display manager. If no desktop environment is specified, prefdm cycles through the gdm, kdm, and
Commenti su questo manuale