Set up a display manager
This section covers material for topic 1.110.2 for the Junior Level Administration (LPIC-1) exam 101. The topic has a weight of 3.
In this section, you learn how to:
- Set up and customize a display manager
- Change the display manager greeting
- Change default bitplanes for the display manager
- Configure display managers for use by X stations
The display managers covered are XDM (X Display Manager), GDM (GNOME Display Manager), and KDM (KDE Display Manager).
In the previous section, if you
installed and configured X on a system that did not have X already installed, you probably
noticed that, to get any kind of graphical display, you must initially log in
to a terminal window and run the
command. While this works for the local display, it is cumbersome. Furthermore,
it does not work for a remote X terminal.
The solution is to use a display manager to present a graphical login screen and handle authentication. Once a user authenticates, the display manager starts a session for the user on the system where the display manager is running. The graphical output is displayed on the screen where the user entered his or her login credentials. This may be a local display or an X display connected across a network.
Both XFree86 and X.Org come with the XDM display manager. Two other display managers are also popular, KDE and GNOME. In this section, you learn how to set up and customize these three display managers.
To set up a graphical login, however, you need to understand Linux system initialization. You can learn more about this in the forthcoming tutorial, LPI exam 102 prep (topic 106): Boot, initialization, shutdown, and runlevels, and in LPI exam 201 prep (topic 202): System startup. In the remainder of this section, you will learn enough to start your system with a graphical login, but the main focus in this section is on setting up and customizing the display manager.
On systems such as Red Hat® and SUSE systems, X is usually started in runlevel 5. Debian systems treat runlevels 2 through 5 as equivalent and default to starting in runlevel 2. The determination of default runlevel is made in /etc/inittab as shown in Listing 9.
Listing 9. Setting the default runlevel in /etc/inittab.
# The default runlevel is defined here id:5:initdefault:
Another line, such as that shown in Listing 10 (for a SUSE system) or Listing 11 (for a Ubuntu system), determines the script or program to be run first.
Listing 10. Initial script for SUSE (or Red Hat) system
# First script to be executed, if not booting in emergency (-b) mode si::bootwait:/etc/init.d/boot
Listing 11. Initial script for Ubuntu (or Debian) system
# Boot-time system configuration/initialization script. # This is run first except when booting in emergency (-b) mode. si::sysinit:/etc/init.d/rcS
The initialization scripts (/etc/init.d/boot or /etc/init.d/rcS) will then run other scripts. Eventually, a series of scripts for the chosen runlevel will be run. For the above examples, these might include /etc/rc2.d/S13gdm (Ubuntu) or /etc/init.d/rc5.d/S16xdm (SUSE), which are both scripts to run a display manager. You will find that the rcn.d directories in /etc/init.d usually contain symbolic links to scripts in /etc/init.d without the leading S (or K) and number. The S indicates that the script should be run when the runlevel is entered, and the K indicates that the script should be run when the runlevel is terminated. The digits specify an order from 1 to 99 in which the scripts should be run.
Hint: Look for scripts that end in dm if you are trying to determine how the display manager is started.
You may find that the script for running a display manager, say /etc/init.d/rc5.d/S16xdm, may be a small script that contains additional logic to determine which display manager will really be run. So, while many systems allow these to be controlled through configuration, you can also find out what display manager will run by examining your initialization files.
It should come as no surprise that you can control whether your display manager is started at system startup simply by creating symbolic links for starting and stopping it in the appropriate rcn.d directory. Furthermore, if you need to stop or start the display manager, you can use the script from /etc/init.d directly as shown in Listing 12.
Listing 12. Stopping and starting a display manager
root@pinguino:~# /etc/init.d/gdm stop * Stopping GNOME Display Manager... [ ok ] root@pinguino:~# /etc/init.d/gdm start * Starting GNOME Display Manager... [ ok ]
Now that you know how to control starting and stopping a display manager, let's look at configuring each of our three display managers.
The X Display Manager (XDM) is included in the XFree86 and X.Org packages. Under the Filesystem Hierarchy Standard, the configuration files should be located in /etc/X11/xdm. The main configuration file is /etc/X11/xdm/xdm-config. This file contains the location of other files used by XDM, information on authorization requirements, the names of scripts run to perform the various tasks for a user, and some other configuration information.
The Xservers file determines which local display or displays should be managed by XDM. It usually contains a single line as shown in Listing 13.
Listing 13. Sample Xservers file
:0 local /usr/X11R6/bin/X :0 vt07
Listing 13 indicates that X should be run on virtual terminal 7. Most systems support using Ctrl-Alt-F1 through Ctrl-Alt-F7 to switch between virtual terminals, where vt01 through vt06 are text-mode terminals, and vt07 is the X terminal.
If you wish to support remote X terminals, then you need an Xaccess file. This file controls how XDM communicates with terminals that support the X Display Manager Control Protocol (XDCMP). Terminals that do not support this protocol are defined in the Xservers file. XDCMP uses the well-known UDP port 177. For security reasons, you should restrict XDCMP use to a trusted internal network with suitable firewall protection.
You can customize the way XDM works by updating the scripts in /etc/X11/xdm. In particular, the Xsetup (or Xsetup_0) script lets you customize the greeting. Figure 2 shows a simple XDM greeting with a digital clock added.
Figure 2. A modified XDM greeting
The source for the modified Xsetup_0 file is shown in Listing 14.
Listing 14. Sample Xsetup_0 file
#!/bin/sh xclock -geometry 80x80 -bg wheat& xconsole -geometry 480x130-0-0 -daemon -notify -verbose -fn fixed -exitOnFail
The greeting shown in Figure 2 came from a system using a 640x480 pixel screen resolution at 256 colors. XDM uses the default resolution from your XF86Config or xorg.conf file. To change your default system-wide screen resolution, you may edit this file or use the utilities that may have come with your system. Listing 15 shows the Screen section of an XF86Config file. Note that the DefaultDepth is 16, so the X server will try to run the screen at the first possible resolution specified for this depth, 1024x768 in this case.
Listing 15. Configuring screen resolution
Section "Screen" DefaultDepth 16 SubSection "Display" Depth 15 Modes "1280x1024" "1024x768" "800x600" "640x480" EndSubSection SubSection "Display" Depth 16 Modes "1024x768" "800x600" "640x480" EndSubSection SubSection "Display" Depth 24 Modes "1280x1024" "1024x768" "800x600" "640x480" EndSubSection SubSection "Display" Depth 32 Modes "1280x1024" "1024x768" "800x600" "640x480" EndSubSection SubSection "Display" Depth 8 Modes "1280x1024" "1024x768" "800x600" "640x480" EndSubSection Device "Device" Identifier "Screen" Monitor "Monitor" EndSection
Depth refers to the number of bits that make up each
pixel. You may also see this called bits per pixel or
bitplanes. Thus, using 8 bitplanes or 8 bits for each color allows up to 256 colors,
while a depth of 16 allows up to 65536 colors. With today's graphic cards, the higher depths of
24 and 32
are now common.
You can check the screen resolution using the
xwininfo command with the
-root option to see the characteristics of your
running X server, as shown in Listing 16.
Listing 16. Checking the screen resolution
ian@lyrebird:~> xwininfo -display 0:0 -root xwininfo: Window id: 0x36 (the root window) (has no name) Absolute upper-left X: 0 Absolute upper-left Y: 0 Relative upper-left X: 0 Relative upper-left Y: 0 Width: 1024 Height: 768 Depth: 16 Visual Class: TrueColor Border width: 0 Class: InputOutput Colormap: 0x20 (installed) Bit Gravity State: NorthWestGravity Window Gravity State: NorthWestGravity Backing Store State: NotUseful Save Under State: no Map State: IsViewable Override Redirect State: no Corners: +0+0 -0+0 -0-0 +0-0 -geometry 1024x768+0+0
KDM is the K Desktop Manager for the K Desktop Environment (KDE). KDE version 3 uses a kdmrc configuration file, a change from earlier versions, which used configuration information that was based on the xdm configuration files. This is located in the $KDEDIR/share/config/kdm/ directory, where $KDEDIR might be /etc/kde3/kdm/ or perhaps somewhere else. For example, on a SUSE SLES8 system, this is located in /etc/opt/kde3/share/config/kdm.
Listing 17. KDM configuration file - kdmrc
[Desktop0] BackgroundMode=VerticalGradient Color1=205,205,205 Color2=129,129,129 MultiWallpaperMode=NoMulti Wallpaper=UnitedLinux-background.jpeg WallpaperMode=Scaled [X-*-Greeter] GreetString=UnitedLinux 1.0 (%h) EchoMode=OneStar HiddenUsers=nobody, BackgroundCfg=/etc/opt/kde3/share/config/kdm/kdmrc MinShowUID=500 SessionTypes=kde,gnome,twm,failsafe [General] PidFile=/var/run/kdm.pid Xservers=/etc/opt/kde3/share/config/kdm/Xservers [Shutdown] HaltCmd=/sbin/halt LiloCmd=/sbin/lilo LiloMap=/boot/map RebootCmd=/sbin/reboot UseLilo=false [X-*-Core] Reset=/etc/X11/xdm/Xreset Session=/etc/X11/xdm/Xsession Setup=/opt/kde3/share/config/kdm/Xsetup Startup=/etc/X11/xdm/Xstartup AllowShutdown=Root [Xdmcp] Willing=/etc/X11/xdm/Xwilling Xaccess=/etc/X11/xdm/Xaccess
Many sections contain the same type of configuration information as for XDM, but there are some differences. For example, the SessionTypes field allows KDM to start any one of several different session types; other commands allow KDM to shut down or reboot the system.
You can configure KDM by editing the kdmrc file. You can also change many of the Login Manager settings by using the KDE control center (kcontrol) as shown in Figure 3.
Figure 3. Modifying KDM configuration with kcontrol
The KDM handbook (see Resources) contains extensive information on KDM configuration.
GDM is the GNOME Desktop Manager for the GNOME Desktop Environment. This desktop manager was not based on XDM, but was written from scratch. GDM uses a gdm.conf configuration file, normally located in the /etc/X11/gdm directory. Listing 18 shows part of a gdm.conf file.
Listing 18. Partial GDM configuration file - gdm.conf
# You should probably never change this value unless you have a weird setup PidFile=/var/run/gdm.pid # Note that a post login script is run before a PreSession script. # It is run after the login is successful and before any setup is # run on behalf of the user PostLoginScriptDir=/etc/X11/gdm/PostLogin/ PreSessionScriptDir=/etc/X11/gdm/PreSession/ PostSessionScriptDir=/etc/X11/gdm/PostSession/ DisplayInitDir=/etc/X11/gdm/Init ... # Probably should not touch the below this is the standard setup ServAuthDir=/var/gdm # This is our standard startup script. A bit different from a normal # X session, but it shares a lot of stuff with that. See the provided # default for more information. BaseXsession=/etc/X11/xdm/Xsession # This is a directory where .desktop files describing the sessions live # It is really a PATH style variable since 18.104.22.168 to allow actual # interoperability with KDM. Note that <sysconfdir>/dm/Sessions is there # for backwards compatibility reasons with 2.4.4.x #SessionDesktopDir=/etc/X11/sessions/:/etc/X11/dm/Sessions/:/usr/share/gdm/Buil\ tInSessions/:/usr/share/xsessions/ # This is the default .desktop session. One of the ones in SessionDesktopDir DefaultSession=default.desktop
Again, you will see some similarities in the type of configuration information used for GDM, KDM, and XDM, although gdm.conf is a much larger file with many more options.
You can configure GDM by editing the gdm.conf file. You can also change
many of the settings by using the
command. Figure 4 shows an alternate graphical greeter available on a
Figure 4. Modifying GDM configuration with gdmsetup
The GNOME Display Manager Reference Manual (available from the gdmsetup help, or see Resources) contains extensive information on GDM configuration.