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

Install and configure X

This section covers material for topic 1.110.1 for the Junior Level Administration (LPIC-1) exam 101. The topic has a weight of 5.

In this section, you learn how to:

  • Check that your video card and monitor are supported by your X server
  • Configure and install X
  • Customize and tune X for the card and monitor
  • Configure and install an X font server
  • Install fonts

History of the X Window System

The X Window System, also known simply as X or X11, is a window system for graphical (bitmap) displays. X originated at MIT in 1984 and was developed as part of Project Athena, which provided a computing environment using disparate hardware. X separates the display functions into a display server and clients, which provide the application logic. It is network transparent, so the display server and the client need not be on the same machine. Note that the sense of "client" and "server" is somewhat opposite to what you might normally think. In addition to handling displayed output, the server end also handles input from devices such as keyboards, mice, graphic tablets, and touchscreens.

X provides a toolkit for GUI applications, but it does not specify a user interface. On a typical Linux system, you will choose between KDE or GNOME desktops, and you may have several other window managers available too. Because X does not specify a user interface, these desktops and window managers have different appearances.

Because X was developed to serve a large community with disparate hardware types, you will find that different versions of X client and server will generally interoperate quite well.

XFree86 and X.Org

By 1987, MIT wanted to hand off control of X, and the MIT X Consortium was founded as a non-profit group to oversee development of X. After a few more stewardship changes, the Open Group formed X.Org in 1999. Since 1992, much of the active development of X was done by XFree86, which had originally created a port of X to the Intel® 386 hardware for use in Linux, hence the name XFree86. XFree86 joined X.Org as a non-paying member.

Although originally created for the 386, later versions of XFree86 supported several different platforms, and it became the most widely used X version on Linux. After some disputes over new licensing terms and the development model of XFree86, the X.Org Foundation was formed. Working from the last XFree86 version under the earlier license, it created X11R6.7 and X11R6.8. Many distributions still use XFree86, while many have picked up X.Org instead.

Video hardware support

Both the XFree86 and X.Org packages support a wide range of modern video cards. Consult the online documentation for your release (see Resources). Some manufacturers do not release open source drivers for all functions, so you may need to integrate a driver from the manufacturer into your XFree86 system. Check the manufacturer's Web site for improved or updated Linux drivers. This is often the case for accelerated 3D drivers. Even if the hardware capabilities of your card cannot be used by XFree86, it is possible that you may be able to run in VESA (Video Electronics Standards Association) framebuffer mode.

Modern monitors implement the VESA Display Data Channel (or DDC) specification, which allows monitor information and capabilities to be determined programatically. The XFree86 configuration tools (other than xf86config) use this information to configure your X system.

One way to see how X works with your hardware is to boot a live CD distribution, such as Knoppix or Ubuntu. These generally have excellent ability to detect and use your hardware. Many distributions offer a graphical installation choice, which also requires correct detection and use of your hardware.


Most distributions include a version of XFree86 or X.Org already packaged for the system. If not, you may be able to find an RPM or .deb package and install it according to the techniques you learned in the tutorial for topic 102, "LPI exam 101 prep: Linux installation and package management."

XFree86 installation

If you do not have an XFree86 package available, then you will need to download the files from XFree86 project Web site (see Resources). Prebuilt packages are available for Linux on several popular hardware platforms, or you may install from the source distribution. This tutorial assumes you will be installing a binary package of the current release (version 4.5.0).

You will need to download several binary packages. You should use the available md5 checksums and the GPG keys to validate your downloads. Table 3 lists the required files for XFree86.

Table 3. XFree86 required files
Xinstall.shInstallation script
extractTarball extraction utility
Xbin.tgzX clients, utilities, and run-time libraries
Xlib.tgzData files required at run-time
Xman.tgzManual pages
Xdoc.tgzXFree86 documentation
Xfnts.tgz Base set of fonts
Xfenc.tgzFont encoding data
Xetc.tgzRun-time configuration files - part 1
Xrc.tgzRun-time configuration files - part 2
Xvar.tgzRun-time data
Xxserv.tgzXFree86 X server
Xmod.tgzX server modules

If you are not sure which version to download, then download the file for the one you think is closest, and use the -check option to check your system as shown in Listing 1.

Listing 1. Checking for the correct XFree86 binary package
root@pinguino:~/xfree86# sh -check
Checking which OS you're running...
uname reports 'Linux' version '2.6.12-10-386', architecture 'i686'.
libc version is '6.3.5' (6.3).

Binary distribution name is 'Linux-ix86-glibc23'

If you don't find a binary distribution with this name, then
binaries for your platform are not available from

For this example, you should look for the "Linux-ix86-glibc23" package.

Table 4 lists the optional files for XFree86. For this tutorial, you will need the font server and any other items that you wish to install.

Table 4. XFree86 optional files
Xdrm.tgzDirect rendering manager (DRM) kernel modules source
Xfsrv.tgzFont server
Xnest.tgz Nested X server
Xprog.tgzX header files, configuration files, and libraries for developing X applications
Xprt.tgzX Print server
Xvfb.tgz Virtual framebuffer X server
Xtinyx.tgz TinyX servers
Xf100.tgz 100dpi fonts
Xfcyr.tgz Cyrillic fonts
Xfscl.tgzScalable fonts (Speedo, Type1, and TrueType)
Xhtml.tgzHTML version of the documentation
Xps.tgzPostScript version of the documentation
Xpdf.tgzPDF version of the documentation

Before you install XFree86, you should make backups of your /usr/X11R6, /etc/X11, and /etc/fonts directories as their contents may be changed by the XFree86 installation. You may use the tar, cp, or zip commands to do this. When you are ready to install XFree86, change to the directory where you downloaded the XFree86 files, and run the script as shown in Listing 2.

Listing 2. Installing XFree86
root@pinguino:~/xfree86# sh 

You will be prompted for answers to several questions, which may vary according to whether or not you have a prior installation of X. After the mandatory components are installed, you will be prompted to install the optional components individually.

Following the file installation, the script will run the ldconfig command and offer to set up several symbolic links for you.

The easiest way to install XFree86 is to install all the components you want using the script. If you do not, you will either need to reinstall the whole package, potentially overwriting any customization you have done, or manually install other components.

XFree86 configuration

Historically, configuring XFree86 involved creating an XF86Config file, which contained information about the video card, mouse, keyboard, and display hardware as well as customization items, such as preferred display resolutions. The original configuration tool, xf86config, required a user to have and enter detailed information about video card and monitor timings. Recent versions of XFree86 are capable of dynamically determining the available hardware and can run with little or no configuration information.

The available configuration tools are:

XFree86 -autoconfig
Running XFree86 with the -autoconfig option will attempt to automatically configure the X server. If your setup is correctly determined, you should be able to move the X cursor around the screen with your mouse. Hold down the Ctrl and Alt keys and press the Backspace key to exit display. This confirms that automatic configuration will work. A configuration file is not written.
XFree86 -configure
Running XFree86 with the -configure option may work if the -autoconfig option does not. This option may also give problems on some systems.
The xf86cfg command attempts to start the display and input drivers. If it is successful, you will see a window with a diagram of your system. Right-click an item to view or update its configuration. On some systems you may need to use the numeric keypad instead of mouse buttons, because the mouse was not properly detected. You may wish to try creating a symbolic link to /dev/mouse from your actual mouse device before running xf86cfg. For example:
ln -s /dev/input/mice /dev/mouse
When you click Quit, you will be prompted to save your /etc/X11R6/lib/X11/XF86Config and /etc/X11R6/lib/X11/xkb/X0-config.keyboard configuration files.
The xf86config command uses a text-mode interface to interactively prompt for information about your mouse, keyboard, video card, and display. You will need horizontal and vertical frequency information for your display. You can select most video cards from a database of known video cards. If not, you may need specific chipset and timing information for your card.


  1. If your system includes XFree86, your distributor may have included a tool, such as the sax2 command used on SUSE systems or the redhat-config-xfree86 command used on some Red Hat® systems. Always check your system documentation for such tools.
  2. Another configuration tool, XF86Setup, is no longer distributed with XFree86.


Most distributions include a version of XFree86 or X.Org already packaged for the system. If not, you may be able to find an RPM or .deb package and install it according to the techniques you learned in the tutorial for topic 102, "LPI exam 101 prep: Linux installation and package management."

X.Org installation

If you do not have an X.Org package available, then you will need to download and build the source from the X.Org Web site or a mirror (see Resources). At the time of this writing, these sites do not contain prebuilt binary packages for X11R6.9.0 or X11R7.0. The source is available from the CVS repository, or as tarballs that are compressed with either gzip or bzip2. You need to get either the gz or bz2 files, not both. You will find the X.Org Modular Tree Developer's Guide (see Resources) an invaluable aid when downloading and building X.Org yourself. Take note of the additional packages, such as freetype, fontconfig, and Mesa, that are recommended for a fully functional build.

X.Org configuration

The X.Org package is based on a recent version of XFree86 and has similar configuration capabilities, including dynamically determining the available hardware. The configuration file is named xorg.conf rather than XF86Config. You may find it in one of several places: /etc/xorg.conf, /etc/X11/xorg.conf, /usr/X11R6/etc/xorg.conf, /usr/X11R6/lib/X11/xorg.conf.hostname, or /usr/X11R6/lib/X11/xorg.conf.

The available configuration tools are:

X -configure
Running X with the -configure option causes the X server to load each driver module, probe for the driver, and create a configuration file that is saved in the home directory of the user who started the server (usually /root). The file is called
This tool is similar to xf86cfg
The xorgconfig command uses a text-mode interface to interactively prompt for information about your mouse, keyboard, video card, and display. As with xf86config, you will need horizontal and vertical frequency information for your display. You can select most video cards from a database of known video cards. If not, you may need specific chipset and timing information for your card.

Tuning X

Modern multisync CRT monitors usually have controls to set the size and position of the displayed image on the screen. If your monitor does not have this capability, you can use the xvidtune command to tune the size and position of your X display. When you run xvidtune from an X terminal session, you will see a window similar to Figure 1. Adjust the settings and click Test to see how they work, or click Apply to change the settings. If you click Show, the current settings will be printed to your terminal window in a format that you can use as a Modeline setting in your CF86Config or xorg.conf file.

Figure 1. Running xvidtune
Running xvidtune

Consult the man page for additional information.

Overview of fonts in X

For many years, font handling on X systems was done by the core X11 fonts system. Recent versions of XFree86 (and X.Org) X servers include the Xft fonts system. The core fonts system was originally designed to support monochrome bitmap fonts, but it has been enhanced over time. The Xft system was designed to handle modern requirements, including anti-aliasing and sub-pixel rasterization and it allows applications to have extensive control over the rendering of glyphs. A major difference between the two systems is that the core fonts are handled on the server, while the Xft fonts are handled by the clients, which send the necessary glyphs to the server.

X originally used Type 1 (or Adobe Type 1) fonts, a font specification developed by Adobe. The Xft system can handle these as well as OpenType, TrueType, Speedo, and CID font types.

The xfs font server

With the core X11 fonts system, the X Server obtains fonts and font information from a font server. The X font server, xfs, usually runs as a daemon and is started at system startup, although it is possible to run it as an ordinary task. You will usually install a font server as part of your X installation. However, because X is a network protocol, it is possible to obtain fonts and font information over a network rather than from your local machine.

The X font server uses a configuration file, normally /usr/X11R6/lib/X11/fs/config. A sample font configuration file is shown in Listing 3. The configuration file may also be located in or linked to /etc/X11/fs.

Listing 3. Sample /usr/X11R6/lib/X11/fs/config
# allow a max of 10 clients to connect to this font server
client-limit = 10

# when a font server reaches its limit, start up a new one
clone-self = on

# alternate font servers for clients to use
#alternate-servers = foo:7101,bar:7102

# where to look for fonts
catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,

# in 12 points, decipoints
default-point-size = 120

# 100 x 100 and 75 x 75
default-resolutions = 75,75,100,100

# how to log errors
use-syslog = on

# don't listen to TCP ports by default for security reasons
no-listen = tcp

This example is typical of a Linux workstation installation where the font server does not provide fonts over TCP network connections (no-listen = tcp).

The Xft library

The Xft library provides functions that allow client applications to select fonts based on pattern criteria and to generate glyphs to send to the server. Patterns take into account items such as font family (Helvetica, Times, and so on), point size, weight (regular, bold, italic), and many other possible characteristics. While the core font system allowed a client to find a match for the first available font on a server, the Xft system finds the best match for all the criteria and then sends the glyph information to the server. Xft interacts with FreeType for font rendering and with the X Render extensions, which help speed up font rendering operations. Xft is included with current versions of both XFree86 and X.Org.

Note: If your X server is running across a network and using a video card that does not support the X Render extensions, you may want to disable anti-aliasing as the network performance in this case may be a problem. You can use the xdpyinfo command to check your X server. Listing 4 shows part of the output from xdpyinfo. Since the output from xdpyinfo is large, you may want to use grep to filter for 'RENDER'.

Listing 4. Checking for RENDER extensions with xdpyinfo
[ian@lyrebird ian]$ xdpyinfo
name of display:    :0.0
version number:    11.0
vendor string:    The XFree86 Project, Inc
vendor release number:    40300000
XFree86 version: 4.3.0
maximum request size:  4194300 bytes
motion buffer size:  256
bitmap unit, bit order, padding:    32, LSBFirst, 32
image byte order:    LSBFirst
number of supported pixmap formats:    7
supported pixmap formats:
    depth 1, bits_per_pixel 1, scanline_pad 32
    depth 4, bits_per_pixel 8, scanline_pad 32
    depth 8, bits_per_pixel 8, scanline_pad 32
    depth 15, bits_per_pixel 16, scanline_pad 32
    depth 16, bits_per_pixel 16, scanline_pad 32
    depth 24, bits_per_pixel 32, scanline_pad 32
    depth 32, bits_per_pixel 32, scanline_pad 32
keycode range:    minimum 8, maximum 255
focus:  window 0x2000011, revert to Parent
number of extensions:    30
default screen number:    0
number of screens:    1

The use of Xft instead of the core X system requires application changes, so you may find that some of your applications do not appear to take advantage of the better font rendering of Xft. At the time of this writing, the Qt toolkit (used for KDE) and the GTK+ toolkit (used for GNOME), as well as Mozilla 1.2 and above, are examples of applications that use Xft.

Installing fonts

There are two methods of installing fonts, one for Xft and a more complex one for the core X11 fonts.

Fonts for Xft

Xft uses fonts located in a set of well-known font directories as well as fonts installed in the .fonts subdirectory of the user's home directory. The well-known font directories include subdirectories of /usr/X11R6/lib/X11/lib/fonts as listed in the catalog entry in /usr/X11R6/lib/X11/fs/config. Other font directories may be specified in the FontPath section XF86Config or xorg.conf, according to which X Server package you are using.

Simply copy your font files to the user's .fonts directory or to a directory such as /usr/local/share/fonts for system-wide use. The font server should pick up the new fonts and make them available at its next opportunity. You can trigger this update with the fc-cache command.

The current font technology in X uses loadable modules to provide font support for different font types as shown in Table 5.

Table 5. X Server font modules
bitmapbitmap fonts (.bdf, .pcf, and .snf)
freetypeTrueType fonts (.ttf and .ttc), OpenType fonts (.otf and .otc) and Type 1 fonts (.pfa and .pfb)
type1Alternate for Type 1 (.pfa and .pfb) and CID Fonts
xttAlternate TrueType module (.ttf and .ttc)
speedoBitstream Speedo fonts (.spd)

If you are having trouble installing and using a font, check the server log (for example, /var/log/XFree86.0.log) to make sure that the appropriate module was loaded. Module names are case sensitive. You can use the xset command to display (and set) X server settings, including the font path and the location of the configuration and log files, as illustrated in Listing 5.

Listing 5. Displaying X server settings with xset
[ian@lyrebird ian]$ xset -display 0:0 -q
Keyboard Control:
  auto repeat:  on    key click percent:  0    LED mask:  00000000
  auto repeat delay:  500    repeat rate:  30
  auto repeating keys:  00ffffffdffffbbf
  bell percent:  50    bell pitch:  400    bell duration:  100
Pointer Control:
  acceleration:  2/1    threshold:  4
Screen Saver:
  prefer blanking:  yes    allow exposures:  yes
  timeout:  0    cycle:  0
  default colormap:  0x20    BlackPixel:  0    WhitePixel:  16777215
Font Path:
Bug Mode: compatibility mode is disabled
DPMS (Energy Star):
  Standby: 7200    Suspend: 7200    Off: 14340
  DPMS is Enabled
  Monitor is Off
Font cache:
  hi-mark (KB): 5120  low-mark (KB): 3840  balance (%): 70
File paths:
  Config file:  /etc/X11/XF86Config
  Modules path: /usr/X11R6/lib/modules
  Log file:     /var/log/XFree86.0.log

If you need to further control the behavior of Xft, you can use either the system-wide configuration file (/etc/fonts/fonts.conf) or a user-specific file (.fonts.conf in the home directory of the user). You can enable or disable anti-aliasing and control sub-pixel rendering (used on LCD displays), among other things. These are XML files, so you need to ensure that you maintain well-formed XML if you edit them. Consult the man (or info) pages for fonts-conf for additional information on the contents and format of these files.

Core X11 fonts

If you have files in Bitmap Distribution Format (.bdf), it is desirable to convert them to Portable Compiled Format (.pcf) using the bdftopcf command and then compress them using gzip before installing them. Once this is done, you may copy your new fonts to a directory, such as /usr/local/share/fonts/bitmap/, and then run the mkfontdir command to create a font directory for use by the font server. These steps are illustrated in Listing 6.

Listing 6. Installing a bitmapped font
[root@lyrebird root]# bdftopcf courier12.bdf -o courier12.pcf
[root@lyrebird root]# gzip courier12.pcf
[root@lyrebird root]# mkdir -p /usr/local/share/fonts/bitmap
[root@lyrebird root]# cp *.pcf.gz /usr/local/share/fonts/bitmap/
[root@lyrebird root]# mkfontdir /usr/local/share/fonts/bitmap/
[root@lyrebird root]# ls /usr/local/share/fonts/bitmap/
courier12.pcf.gz  fonts.dir

Note that the mkfontdir command created the fonts.dir file.

When installing scalable fonts, such as TrueType or Type1 fonts, an extra step is required to create scaling information. After you copy the font files to the target directory, run the mkfontscale command and then the mkfontdir command. The mkfontscale command will create an index of scalable font files in a file called fonts.scale.

Once you have set up the font directory and scaling information for your new fonts, you need to tell the server where to find them, by including the new directory in the font path. You can do this temporarily by using the xset command or permanently by adding a FontPath entry to XF86Config or xorg.conf. To add the new bitmap font directory to the front of the font path, use the +fp option of xset as shown in Listing 7.

Listing 7. Updating the fontpath with xset
[ian@lyrebird ian]$  xset +fp /usr/local/share/fonts/bitmap/ -display 0:0

Although not shown here, it is a good idea to add scalable fonts before bitmapped fonts in the path as this results in better font matching. To add directories to the back of the path, use the fp+ option. Similarly, the use of -fp and fp- options will remove font directories from the front and back of the font path, respectively.

You can make permanent modifications to the font path by editing the XF86Config or xorg.conf file. You can add as many FontPath lines as you need in the Files section, as shown in Listing 8.

Listing 8. Updating XF86Config or xorg.conf
Section "Files"
# RgbPath is the location of the RGB database.  Note, this is the name of the
# file minus the extension (like ".txt" or ".db").  There is normally
# no need to change the default.

# Multiple FontPath entries are allowed (they are concatenated together)
# By default, Red Hat 6.0 and later now use a font server independent of
# the X server to render fonts.

        RgbPath      "/usr/X11R6/lib/X11/rgb"
        FontPath     "unix/:7100"
        FontPath     "/usr/local/share/fonts/bitmap/"

For information on other modifications you can make to the X configuration files, see the man pages for either XF86Config or xorg.conf, as appropriate.

2 of 6 | Previous | Next


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