Book: LPI Linux Certification in a Nutshell Section: Chapter 18. X (Topic 2.10)
### 18.2 Objective 1: Install and Configure XFree86 Most Linux distributions install and automatically configure XFree86, freeing users from much of its installation and configuration. However, Exam 102 requires specific knowledge of some of the underpinnings of X configuration.
| Be careful about installing an X server on a system that already has X installed. A backup should be made prior to the installation.
#### 18.2.1 Selecting and Configuring an X Server The XFree86 project provides support for an amazing array of graphics hardware. This outcome is possible partly due to cooperation by manufacturers through public release of graphics device documentation and driver software, and partly due to the tenacity of the XFree86 developers. Fortunately, many manufacturers who were historically uninterested in offering technical information to the XFree86 project have become cooperative. The result is that most recent video hardware is well-supported by XFree86. ##### 18.2.1.1 Supported video hardware To avoid problems, it is important to verify XFree86 compatibility with your hardware prior to installation. At the very least, you should be aware of these items: Your XFree86 version As with any software, improvements in XFree86 are made over time, particularly in support for hardware devices. You should choose a version of XFree86 that offers a good balance between the video support and stability you require. To determine the version of X you're running, simply issue the following command:
    $ /usr/X11R6/bin/X -version
    XFree86 Version 4.0.1a / X Window System
The video chipset XFree86 video drivers are written for graphics chipsets, not the video cards they're installed on. Multiple video cards from a variety of manufacturers can carry the same chipset, making those cards nearly identical in function. You must verify that the chipset on your video card is supported by XFree86 to use advanced graphics features. Monitor type XFree86 can be configured to handle just about any monitor, particularly the newer and very flexible multisync monitors sold today, which can handle preset configurations provided in the XFree86 configuration utilities. However, if you have a nonstandard monitor, you need to know some parameters describing its capabilities before configuring X, including your monitor's horizontal sync frequency (in kHz), vertical refresh frequency (in Hz), and resolution (in pixels). These items can usually be found in your monitor's documentation, but since most monitors conform to standard display settings such as XGA (1024 x 768 pixels at 60 Hz vertical refresh), you should be able to use a preset configuration. As an example of these considerations, suppose you're using a Number Nine video chipset in your system.[1] If you examine the chipset support information included with XFree86 Version 3.3.6, you'll find that the I128 driver handles your chipset. However, XFree86 Version 4.0.1 does not, so v4.0.1 is not a viable choice. Your chipset must be supported by the version of XFree86 you're installing. Check the XFree86 release notes for specific information on supported chipsets. [1] Number Nine was the manufacturer of some popular PC video hardware. The company is now out of business. ##### 18.2.1.2 Installing XFree86 from packages The procedures for installation vary depending on the release of X you're using. For example, with versions prior to 4.0, a specific X server is required to match your chipset in order to use modes other than standard VGA. For versions after 4.0, a newer modular design allows a single server program to manage all supported chipsets by calling driver modules. In addition, the type of XFree86 distribution you're using affects installation. XFree86 is available as source code, in precompiled binary form, or as an RPM or Debian package. (Because of the precompiled and package options, there's little reason to compile from scratch.) If you're going to use a version of XFree86 that came with a Linux distribution, simply use the package installation tools from your distribution with the XFree86 packages. For example, on a Red Hat 6.0 system with XFree86 v3.3.3.1, the following components of XFree86 were installed by the RPM package:[2] [2] In this example, all of the package names are followed by a version number. Here, XFree86 v3.3.3.1 is installed.
    XFree86-SVGA-3.3.3.1-49
    X11R6-contrib-3.3.2-6
    Xconfigurator-4.2.3-1
    XFree86-3.3.3.1-49
    XFree86-75dpi-fonts-3.3.3.1-49
    XFree86-libs-3.3.3.1-49
    XFree86-xfs-3.3.3.1-49
    XFree86-XF86Setup-3.3.3.1-49
The first item in this list is the SVGA X server (XFree86-SVGA-3.3.3.1-49), which supports a number of video chipsets (other server programs, packaged separately, may be needed to support other video chipsets). The XFree86 package (XFree86-3.3.3.1-49 in the list) is the core of XFree86. The other items are either required or recommended packages. Such recommendations can come from the installation program or from notes accompanying the package. For example, the XFree86 package indicates that: In addition to installing the [XFree86] package, you will need to install the XFree86 package [that] corresponds to your video card, the X11R6-contrib package, the Xconfigurator package, and the XFree86-libs package. You may also need to install one of the XFree86 fonts [sic] packages. Using a packaged installation targeted for your particular Linux distribution will probably be the simplest method. ##### 18.2.1.3 Installing XFree86 from precompiled binaries You may wish to try a version of XFree86 that is more recent than available packaged versions. In this case, you may wish to install a precompiled binary from the XFree86 project. To get the files needed to install the latest version, consult the XFree86 web site or one of the many mirror sites listed there. The first step in deploying a precompiled XFree86 binary is to get the configuration program, Xinstall.sh.[3] Using the -check option, this utility can determine which precompiled binary distribution is right for your system: [3] It's important to use binary-mode FTP to get this program. Browsers may not transfer the program correctly.
    # ./Xinstall.sh -check
    Checking which OS you're running...
    uname reports 'Linux' version '2.2.5-15smp',
      architecture 'i686'.
    Object format is 'ELF'.  libc version is '6.1'.
    Binary distribution name is 'Linux-ix86-glibc21'
The last line directs us to the appropriate binary distribution, which in this case is Linux-ix86-glibc21 (your results will differ). Next we need to get the files for that distribution. Some, such as fonts and extra programs, are optional. Details on exactly which files to get are available in the Install document, which may be retrieved along with Xinstall.sh. The files listed in Table 18-1 are mandatory for use with v4.0.1.

##### Table 18-1. Files Necessary for Use with XFree86 v4.0.1

Filename | Description
--- | ---
Xinstall.sh | The installer script
extract | The utility for extracting tarballs
Xbin.tgz | X clients/utilities and runtime libraries
Xlib.tgz | Some data files required at runtime
Xman.tgz | Manual pages
Xdoc.tgz | XFree86 documentation
Xfnts.tgz | Base set of fonts
Xfenc.tgz | Base set of font-encoding data
Xetc.tgz | Runtime configuration files
Xvar.tgz | Runtime data
Xxserv.tgz | XFree86 X server
Xmod.tgz | XFree86 X server modules
After you have retrieved these files, simply run Xinstall.sh as root to begin installation as described in the Install document. ##### 18.2.1.4 Configuring an X server and the XF86Config file XFree86 configuration differs slightly among versions and among Linux distributions, but essentially involves the creation of the XF86Config file customized for your system. The X server uses this configuration file as it starts to set such things as keyboard and mouse selections, installed fonts, and screen resolutions. XF86Config contains technical details concerning the capabilities of system hardware, which can be intimidating for some users. For this reason, automated configuration tools are available that will generate the file for you: xf86config This program is distributed with XFree86. It is a simple text-mode program that requests information about the system from the user and then writes a corresponding XF86Config file. This utility does not use information stored in an existing configuration file, so its utility is limited. (Remember that xf86config is a binary program that writes the XF86Config text file.) XF86Setup This program is distributed with XFree86. XF86Setup is a graphical program that starts a VGA X server, which should run on most PC hardware. It allows you to select the graphics chipset, monitor, mouse, and keyboard device types and writes the appropriate configuration file for you. xf86cfg This program is distributed with XFree86 v4.0. Like XF86Setup, it is a graphical tool; however, xf86cfg's interface is slightly different. Whereas other tools offer a menu-based approach, xf86cfg offers a block diagram of the system, including a monitor, video device, keyboard, and mouse. The user configures each element by manipulating its properties. When the user is happy with the configuration, the tool writes the XF86Config file. Distribution-specific tools Various Linux distributors provide their own configuration utilities. For example, Xconfigurator is distributed by Red Hat Software. It is menu-based, provides for automated probing of graphics chipsets and capabilities, and uses a list of known monitors to retrieve timing information. Example 18-1 contains an abbreviated XF86Config file created using the Red Hat Xconfigurator tool for XFree86 v3.3.3.[4] [4] The XF86Config files shown here are examples and are not intended for use on your system. ##### Example 18-1. A sample XF86Config File for XFree86 v3.3.3
    # File generated by XConfigurator.

    Section "Files"
        RgbPath    "/usr/X11R6/lib/X11/rgb"
        FontPath   "unix/:-1"
    EndSection

    Section "ServerFlags"
    EndSection

    Section "Keyboard"
        Protocol    "Standard"
        AutoRepeat  500 5
        LeftAlt     Meta
        RightAlt    Meta
        ScrollLock  Compose
        RightCtl    Control
        XkbDisable
        XkbKeycodes     "xfree86"
        XkbTypes        "default"
        XkbCompat       "default"
        XkbSymbols      "us(pc101)"
        XkbGeometry     "pc"
        XkbRules        "xfree86"
        XkbModel        "pc101"
        XkbLayout       "us"
    EndSection

    Section "Pointer"
        Protocol    "PS/2"
        Device      "/dev/mouse"
        Emulate3Buttons
        Emulate3Timeout    50
    EndSection

    Section "Monitor"
        Identifier  "My Monitor"
        VendorName  "Unknown"
        ModelName   "Unknown"
        HorizSync   31.5 - 64.3
        VertRefresh 50-90
        # 1280x1024 @ 61 Hz, 64.2 kHz hsync
        Mode "1280x1024"
            DotClock    110
            Htimings    1280 1328 1512 1712
            Vtimings    1024 1025 1028 1054
        EndMode
    EndSection

    Section "Device"
        Identifier  "My Video Card"
        VendorName  "Unknown"
        BoardName   "Unknown"
        VideoRam    16256
    EndSection

    Section "Screen"
        Driver      "svga"
        Device      "My Video Card"
        Monitor     "My Monitor"
        Subsection "Display"
            Depth       32
            Modes       "1280x1024"
            ViewPort    0 0
        EndSubsection
    EndSection
Under v3.3.3, the default location for the XF86Config file is in /etc/X11. The file contains the following sections: Files This section is used to specify the default font path and the path to the RGB database. Using the `FontPath` `"``path``"` directive multiple times creates a list of directories that the X server will search for fonts. The RGB database is an equivalence table of numeric red/green/blue color values with names. Here's a short excerpt of the RGB database:
    255 228 196             bisque
    255 218 185             peach puff
    255 218 185             PeachPuff
    255 222 173             navajo white
Hundreds of these names are defined and may be used in the configuration of X applications where color names are required. ServerFlags This section allows customization of X server options such as the handling of hotkeys. Keyboard This section is used to specify the keyboard input device, its parameters, and default keyboard-mapping options. Pointer This section is used to define the pointing device (mouse). Monitor Multiple `Monitor` sections are used to define the specifications of monitors and a list of video modes they can handle. Device Multiple `Device` sections are used to define video hardware (cards) installed. Screen The `Screen` section ties together a `Device` with a corresponding `Monitor` and includes some configuration settings for them.
## On the Exam You don't need to memorize details about XF86Config, but it is an important file, and your familiarity with it will be tested. In particular, be aware of what each of the sections does for the X server, and remember that the `Screen` section ties together a `Device` and a `Monitor`.
The XF86Config file format was modified slightly for XFree86 v4.0. In particular, a new `ServerLayout` section has been added; it ties the `Screen`, `Pointer`, and `Keyboard` sections together. Example 18-2 contains an abbreviated XF86Config file created using the bundled xf86cfg tool from the XFree86 project. ##### Example 18-2. A Sample XF86Config File for XFree86 v4.0.1
    Section "ServerLayout"
        Identifier     "XFree86 Configured"
        Screen      0  "Screen0" 0 0
        InputDevice    "Mouse0" "CorePointer"
        InputDevice    "Keyboard0" "CoreKeyboard"
    EndSection

    Section "Files"
    EndSection

    Section "InputDevice"
        Identifier  "Keyboard0"
        Driver      "keyboard"
    EndSection

    Section "InputDevice"
        Identifier  "Mouse0"
        Driver      "mouse"
        Option      "Protocol" "PS/2"
        Option      "Device" "/dev/mouse"
    EndSection

    Section "Monitor"
        Identifier   "Monitor0"
        VendorName   "Monitor Vendor"
        ModelName    "Monitor Model"
        HorizSync    31.5 - 64.3
        VertRefresh  50.0 - 90.0
    EndSection

    Section "Device"
        Identifier  "Card0"
        Driver      "nv"
        VendorName  "NVidia"
        BoardName   "Riva TNT"
        ChipSet     "RIVATNT"
        BusID       "PCI:1:0:0"
    EndSection

    Section "Screen"
        Identifier    "Screen0"
        Device        "Card0"
        Monitor       "Monitor0"
        DefaultDepth  24
        SubSection "Display"
            Depth     24
        EndSubSection
    EndSection
Under v4.0, the default location for the XF86Config file is in /etc/X11. The file contains the following sections: ServerLayout This section ties together `Screen` with one or more `InputDevice`s. Multiple `ServerLayout` sections may be used for multiheaded configurations (i.e., systems with more than one monitor). Files This section is used to add paths to fonts and color information, just as it is in XFree86 v3.3.3. InputDevice Multiple `InputDevice` sections should be used to include at least a keyboard and mouse. Subsections within `InputDevice` in v4.0 replace the `Pointer` and `Keyboard` sections for XFree86 v3.3.3. Monitor This section is similar to the `Monitor` section for XFree86 v3.3.3, except that mode specifications are not usually necessary. The X server is already aware of standard VESA video modes and chooses the best mode based on the horizontal sync and vertical refresh rates. Device This section specifies the modular driver for the X server. Multiple `Device` sections can be included to handle multiple graphics devices. Screen This section ties together a `Monitor` with a `Device` and is specified in the `ServerLayout`. Multiple `Screen` sections can be included to handle multiple monitor/device pairs.
## On the Exam As already mentioned, you don't need to worry about details in XF86Config. However, you should be aware of the major differences in the configuration files for XFree86 Versions 3.3 and 4.0.
#### 18.2.2 X Fonts XFree86 is distributed with a collection of fonts for most basic purposes, including text displays in terminal windows and browsers. For many users, the default fonts are adequate, but others may prefer to add additional fonts to their system. A variety of fonts are available, both free and commercially, from many sources, such as Adobe. Some very creative fonts are created by individuals and distributed on the Internet (a search engine should return some useful links to a query such as "XFree86 fonts" ). XFree86 makes fonts that it finds in the font path available to client programs. A basic font path is compiled into the X server, but you can specify your own font path using the `FontPath` directive in the Files section of XF86Config. The simple syntax is:
    FontPath "path"
For example:
    Section "Files"
        RgbPath    "/usr/X11R6/lib/X11/rgb"
        FontPath   "/usr/X11R6/lib/X11/fonts/misc"
        FontPath   "/usr/X11R6/lib/X11/fonts/Type1"
        FontPath   "/usr/X11R6/lib/X11/fonts/Speedo"
        FontPath   "/usr/X11R6/lib/X11/fonts/100dpi"
        FontPath   "/usr/X11R6/lib/X11/fonts/75dpi"
        FontPath   "/usr/X11R6/lib/X11/fonts/local"
    EndSection
This group of `FontPath` directives creates a font path consisting of six directories, all under /usr/X11R6/lib/X11/fonts. When XFree86 starts, it parses these font directories and includes their contents in the list of fonts available during the X session. ##### 18.2.2.1 Installing fonts Adding new fonts is straightforward.[5] First, a suitable directory should be created for the new fonts, such as /usr/X11R6/lib/X11/local or /usr/local/fonts. You may wish to separate your own fonts from the default XFree86 directories to protect them during upgrades. After the fonts are installed in the new directory, the mkfontdir utility is run to catalog the new fonts in the new directory. New entries are added to the XF86Config file to include the path for new fonts. For example: [5] For this brief discussion, we assume that we're working with Type 1 fonts. Other types, such as TrueType fonts, may require additional configuration depending on your version of XFree86.
    FontPath   "/usr/local/fonts"
At this point, the X server can be restarted to recognize the new fonts, or the fonts can be dynamically added using the xset command:
    # xset fp+ /usr/local/fonts
xset is beyond the scope of the LPIC Level 1 exams.
## On the Exam Be sure you understand how the X font path is created and how to extend it to include additional directories. Knowledge of the internal details of font files is not necessary.
##### 18.2.2.2 The X font server On a network with multiple workstations, managing fonts manually for each system can be time consuming. To simplify this problem, the administrator can install all of the desired fonts on a single system and then run xfs, the X fonts server, on that system. The X font server is a small daemon that sends fonts to clients on both local and remote systems. Some Linux distributions use xfs exclusively, without a list of directories in the manually created font path. To include xfs in your system's font path, add a `FontPath` directive like this:
    Section "Files"
        RgbPath     "/usr/X11R6/lib/X11/rgb"

        FontPath   "unix/:-1"
    EndSection
If you install xfs from a package from your distribution, it is probably automatically configured to start at boot time and run continually, serving fonts to local and remote client programs. To start xfs manually, simply enter the xfs command. For security purposes, you may wish to run xfs as a non-root user. xfs is configured using its configuration file, /etc/X11/fs/config. Example 18-3 contains an example config file for xfs. ##### Example 18-3. Sample configuration File for xfs
    # Allow a max of four clients to connect to this font server
    client-limit = 4

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

    catalogue = /usr/X11R6/lib/X11/fonts/misc:unscaled,
            /usr/X11R6/lib/X11/fonts/75dpi:unscaled,
            /usr/X11R6/lib/X11/fonts/100dpi:unscaled,
            /usr/X11R6/lib/X11/fonts/misc,
            /usr/X11R6/lib/X11/fonts/Type1,
            /usr/X11R6/lib/X11/fonts/Speedo,
            /usr/X11R6/lib/X11/fonts/75dpi,
            /usr/X11R6/lib/X11/fonts/100dpi,
            /usr/share/fonts/ISO8859-2/100dpi,
            /usr/share/fonts/ISO8859-9/100dpi
            /usr/X11R6/lib/X11/fonts/local

    # 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
As you can see, the config file contains the following keyword =value pairs: catalogue This keyword holds a comma-separated list of directories containing fonts to be served by xfs. This is where new font directories are added. alternate-servers (strings) This section contains a listing of alternate font servers that can be found on the local machine or on other machines. client-limit This shows the maximum number of client requests to be served. clone-self When `on`, the font server makes copies of itself if it reaches the `client-limit`. You don't need to remember details about the contents of the xfs configuration file (config), but be aware of the use and general contents of the file. In particular, remember that the `catalogue` keyword is used similarly to `FontPath` in XF86Config.
## On the Exam Remember that xfs can take the place of the list of directories in a manually configured font path. However, running xfs doesn't replace the font path -- xfs itself must be on that path as noted earlier in Example 18-1 with the unix/:-1 entry.
#### 18.2.3 Controlling X Applications with .Xresources The X Window System also has many built-in customization features. Many X applications are programmed with a variety of resources, which are configuration settings that can be externally manipulated. Rather than have a configuration utility built into each application, applications can be written to examine the contents of a file in the user's home directory. The .Xresources file contains a line for each configured resource in the following form:
    program*resource: value
This line can be translated as follows: `program` is the name of a configurable program, such as `emacs` or `xterm` . `resource` is one of the configurable settings allowed by the program, such as colors. `value` is the setting to apply to the resource. For example, the following is an excerpt from .Xresources that configures colors for an `xterm` :
    xterm*background: Black
    xterm*foreground: Wheat
    xterm*cursorColor: Orchid
    xterm*reverseVideo: false
## On the Exam You should be aware of X resources and the function of the .Xresources file. In particular, you should understand that X applications will look in the .Xresources file for settings. You should also be able to construct a resource setting given a particular example, but you do not need to be able to generate a configuration file from scratch.