Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your profile (name, country/region, and company) is displayed to the public and will accompany any content you post. You may update your IBM account at any time.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

developerWorks Community:

  • Close [x]

LPI exam 101 prep: The X Window System

Junior Level Administration (LPIC-1) topic 110

Ian Shields, Senior Programmer, IBM
Ian Shields
Ian Shields works on a multitude of Linux projects for the developerWorks Linux zone. He is a Senior Programmer at IBM at the Research Triangle Park, NC. He joined IBM in Canberra, Australia, as a Systems Engineer in 1973, and has since worked on communications systems and pervasive computing in Montreal, Canada, and RTP, NC. He has several patents and has published several papers. His undergraduate degree is in pure mathematics and philosophy from the Australian National University. He has an M.S. and Ph.D. in computer science from North Carolina State University. You can contact Ian at
(An IBM developerWorks Contributing Author)

Summary:  In this tutorial, Ian Shields continues preparing you to take the Linux Professional Institute® Junior Level Administration (LPIC-1) Exam 101. In this fifth in a series of five tutorials, Ian introduces you to the X Window System on Linux®. By the end of this tutorial, you will know how to install and maintain the X Window System. This tutorial covers both major packages for X on Linux: XFree86 and X.Org.

View more content in this series

Date:  02 Jul 2006
Level:  Intermediate PDF:  A4 and Letter (560 KB | 32 pages)Get Adobe® Reader®

Activity:  25114 views

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).

Display managers

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 startx 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

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

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.

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
A modified XDM greeting

The source for the modified Xsetup_0 file is shown in Listing 14.

Listing 14. Sample Xsetup_0 file
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"
  SubSection "Display"
    Depth      16
    Modes      "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth      24
    Modes      "1280x1024" "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth      32
    Modes      "1280x1024" "1024x768" "800x600" "640x480"
  SubSection "Display"
    Depth      8
    Modes      "1280x1024" "1024x768" "800x600" "640x480"
  Device       "Device[0]"
  Identifier   "Screen[0]"
  Monitor      "Monitor[0]"

Note that 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

GreetString=UnitedLinux 1.0 (%h)





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
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
# 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
# Probably should not touch the below this is the standard setup
# 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.
# This is a directory where .desktop files describing the sessions live
# It is really a PATH style variable since to allow actual
# interoperability with KDM.  Note that <sysconfdir>/dm/Sessions is there
# for backwards compatibility reasons with 2.4.4.x
# This is the default .desktop session.  One of the ones in SessionDesktopDir

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 gdmsetup command. Figure 4 shows an alternate graphical greeter available on a Fedora system.

Figure 4. Modifying GDM configuration with gdmsetup
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.

3 of 6 | Previous | Next


Zone=Linux, Open source
TutorialTitle=LPI exam 101 prep: The X Window System