LPI Linux LPIC1

Module 6

Module Contents

• 1 Evans Ikua Lead Editor Kenya [email protected] • 2 Chris Brown Content Author UK [email protected] • 3 Mark Clarke Content Author RSA [email protected] • 4 Brian Ssennoga Content Author Uganda [email protected] • 5 Trust Zifa Material co-editor Zimbabwe [email protected] • 6 John Matogo Material co-editor Kenya john [email protected] • 7 Ken Mutua Material co-editor Kenya [email protected] • 8 Bernard Owuor Material co-editor Kenya [email protected] • 9 Sisay Adugna Material co-editor Ethiopia [email protected] • 10 Balthas Seibold Senior Project • Manager - GIZ • Germany [email protected] • 11 Petra Hagemann Project Manager - GIZ Germany [email protected] • 12 George Nyambuya Africa Coordinator - • ict@innovation • RSA [email protected] • 13 David Paulus Intern - GIZ Germany [email protected] Module Contents

User Interfaces and Desktops • Install and configure X11 • Set up a display manager • Accessibility Module Contents

Configuring X11R6 Two of the configuration utilities provided with the Xfree86 software (which is a raw Xwindow system) are the XF86Setup and xf86config scripts. Other vendors have specific utilities such as: • Xconfigurator, • redhat-config- (RedHat) • XFdrake (Mandrake) • sax (Suse) Once the server has been configured one can change the horizontal and vertical settings for the monitor with xvidtune. Module Contents

Configuring X11R6 Basic X configuration specifies features such as the mouse used, the keyboard layout, the screen resolution, the video refresh rate, the display colour depth, and the video card you’re using. Some of these options require telling X about what hardware you have installed, whereas others enable you to adjust settings on your hardware. In any event, before you proceed with actual confi guration you should know something about the X servers that are available for Linux, because your selection will determine what additional tools are available and what fi les you may need to adjust manually. GUI and text-mode confi guration utilities can help you confi gure X; but sometimes you must delve into the confi guration fi les, so knowing their format is important. This requires that you know what the major option groups do so you can adjust them. Module Contents

X Server Options for Linux Although X is by far the dominant GUI for Linux, several implementations of X are available: XFree86 The dominant X server in Linux until 2004 was XFree86 (http://www.xfree86.org). This open source server supports a wide array of video cards and input devices, and most Linux software was originally designed with XFree86 in mind. As I write, the most recent version is 4.8.0. Signifi cant changes occurred between 3.3.6 and the 4.x series, and some older utilities work only with the 3.3.6 and earlier versions of XFree86. Although a tiny number of elderly systems must run XFree86 3.3.6 or earlier for driver support reasons, most systems today run XFree86 4.x or X.org-X11; the latter is more common on distributions released since 2004. Module Contents

X Server Options for Linux X.org-X11 In 2004, most Linux distributions shifted from XFree86 to X.org-X11 because of licensing changes to XFree86. X.org-X11 6.7.0 was based on XFree86 4.3.99, but it’s developed independently up to the current version, 7.7. Because X.org-X11 is based on XFree86, the two are virtually identical in most important respects. One significant difference is the name of the configuration file; another is the default location for fonts. Subsequent sections of this chapter point out these differences. You can learn more at http://www.x.org/wiki/. Module Contents

Methods of Configuring X Configuring X has traditionally been a difficult process because the X configuration file includes many arcane options. The task is made simpler if you can use a configuration utility, and most Linux distributions now run such a utility as part of the installation process. If the configuration utility doesn’t do everything you want it to do, though, you may need to delve into the X configuration fi le to set options manually, so knowing something about its format will help a lot. You must also know how to go about restarting X in order to test your changes. Module Contents X Configuration Utilities Several configuration tools for XFree86 4.x and X.org- X11 are available: The X Server itself includes the capacity to query the hardware and produce a configuration fi le. To do this, type XFree86 -configure (for XFree86) or Xorg -configure (for X.org-X11) as root when no X server is running. The result should be a fi le called /root/XF86Config.new (for XFree86) or /root/xorg.conf.new (for X.org- X11). This fi le may not produce optimal results, but it’s at least a starting point for manual modifications. Module Contents

The X Configuration File Format The X configuration fi le’s name and location vary with the version of X being run: X.org-X11 This server’s configuration fi le is called xorg.conf, and it’s usually stored in /etc/X11, although /etc and several other locations are also acceptable to the server. XFree86 4.x The XFree86 4.x configuration fi le is called XF86Config-4 or XF86Config, which is found in /etc/X11 or sometimes in /etc. This fi le’s format is the same as for the X.org-X11 confi guration fi le. Module Contents

Configuring X11R6 All the mentioned configuration utilities will create and edit the XF86Config / Xorg configuration file. This file is read at start up by the X Server and determines its behavior. This file is typically found in the /etc/X11 directory, and this is its’ full path: /etc/X11/XF86Config. Typically there are 11 configuration sections in the configuration file: Module Contents

Configuring X11R6 • ServerFlags • Module • InputDevice • Device • VideoAdapter • Monitor • Modes • Screen • ServerLayout • DRI • Vendor Module Contents

Configuring X11R6 Section “InputDevice” Identifier “Keyboard0” Driver “kbd” Option “XkbModel” “pc105” Option “XkbLayout” “us” Option “AutoRepeat” “500 200” EndSection

This section tells X about the keyboard—its model, layout, and so on. Details for the sections you’re most likely to need to adjust are described shortly, in “X Configuration Options.” Module Contents

Configuring X11R6 - Loading Modules The Module section controls the loading of X server modules—drivers for specific features or hardware. A typical example looks like this: Section “Module” Load “dbe” Load “extmod” Load “fbdevhw” Load “” Load “record” Load “freetype” Load “type1” Load “dri” EndSection Module Contents

Configuring X11R6 - Loading Modules Each module is named (dbe, extmod, and so on) and is loaded by name using the Load option. For the most part, if an X configuration works, you shouldn’t try to adjust the Module section, even if you want to tweak the X configuration. Sometimes, though, you’ll need to add lines to or remove lines from this section. This is particularly likely to be necessary if you’re activating 3D acceleration support or some sort of exotic feature. In such cases, you should consult the documentation for the feature you want to activate. Module Contents

Configuring X11R6 - Setting the Keyboard The keyboard is one of two common input devices confi gured via an InputDevice section: Section “InputDevice” Identifier “Keyboard0” Driver “kbd” Option “XkbModel” “pc105” Option “XkbLayout” “us” Option “AutoRepeat” “500 200” EndSection The Identifier line provides a label that’s used by another section (ServerLayout, described in “Putting It All Together”). The string given on this line is arbitrary, but for a keyboard, a descriptive name such as this example’s Keyboard0 will help you understand the fi le. Module Contents Configuring X11R6 - Setting the Keyboard The Driver line tells X what driver to use to access the keyboard. This should be kbd, Keyboard, or evdev, depending on your X server. The kbd and Keyboard drivers are, as you might expect, keyboard-specific drivers. The evdev driver, by contrast, is a generic input device driver that works with many types of input devices. Unless your keyboard isn’t working at all, you shouldn’t adjust this line. The Option lines set various options that adjust keyboard features, such as the model, the layout, and the repeat rate. Module Contents

Configuring X11R6 - Setting the Mouse A second InputDevice section controls how X treats the mouse: Section “InputDevice” Identifier “Mouse0” Driver “mouse” Option “Protocol” “IMPS/2” Option “Device” “/dev/input/mice” Option “Emulate3Buttons” “no” Option “ZAxisMapping” “4 5” EndSection Module Contents

Configuring X11R6 - Setting the Mouse As with the keyboard, the Identifier line is used in the ServerLayout section to tell X which input device to use. The Driver line identifi es the driver to use: mouse. (Many modern systems use evdev for the mouse.) The Option lines set mouse control options. The most important of these are Device and Protocol. Module Contents

Configuring X11R6 - Setting the Mouse The Device line tells X what Linux device fi le to read to access the mouse. In this example, it’s /dev/input/mice, but other possibilities include /dev/mouse (a pointer to the real mouse device, whatever its name), /dev/psaux (for the PS/2 mouse port), /dev/usb/usbmouse (an old identifi er for USB mice), /dev/ttyS0 (the fi rst RS-232 serial port mouse), and /dev/ttyS1 (the second RS-232 serial port mouse). The Protocol option tells X what signals to expect from the mouse for various movements and button presses. The Auto protocol causes X to try to guess the mouse’s protocol, which usually works correctly. Module Contents

Configuring X11R6 - Setting the Monitor Some of the trickiest aspects of X configuration relate to the monitor options. You set these in the Monitor section, which can sometimes be quite large. A modest Monitor section looks like this: Section “Monitor” Identifier “Monitor0” ModelName “AOC e2343Fk” HorizSync 30.0 - 83.0 VertRefresh 55.0 - 75.0 # My custom 1920x1080 mode Modeline "1920x1080“ 138.50 1920 1968 2000 2080 1080 1083 1088 1111 EndSection Module Contents

Configuring X11R6 - Setting the Monitor As in the keyboard and mouse configurations, the Identifier option is a free-form string that contains information that’s used to identify a monitor. The Identifier can be just about anything you like. Likewise, the ModelName option can be anything you like; it’s used mainly for your own edification when reviewing the configuration file. As you continue down the section, you’ll see the HorizSync and VertRefresh lines, which are extremely critical; they define the range of horizontal and vertical refresh rates that the monitor can accept, in kilohertz (kHz) and hertz (Hz), respectively. Together, these values determine the monitor’s maximum resolution and refresh rate. Despite the name, the HorizSync item alone doesn’t determine the maximum horizontal refresh rate. Rather, this value, the VertRefresh value, and the resolution determine the monitor’s maximum refresh rate. Module Contents

Configuring X11R6 - Choosing the Driver Sometimes X, and particularly modern versions of X.org-X11, can pick the optimum video driver automatically. Other times, though, you must provide that information in the XF86Config or xorg.conf fi le. In particular, the driver module is set by a line in the Device section, which resembles the following: Section “Device” Identifier “Videocard0” Driver “nv” VendorName “nVidia” BoardName “GeForce 6100” VideoRam 131072 EndSection Module Contents

Configuring X11R6 - Choosing the Driver The Identifier line provides a name that’s used in the subsequent Screen section to identify this particular Device section. The VendorName and BoardName lines provide information that’s useful mainly to people reading the fi le. The VideoRam line is unnecessary with most boards because the driver can detect the amount of RAM installed in the card. With some devices, however, you may need to specify the amount of RAM installed in the card, in kilobytes. For instance, the preceding example indicates a card with 128MB of RAM installed. Module Contents

Configuring X11R6 - Setting the Resolution and Color Depth The Screen section tells X about the combination of monitors and video cards you’re using. XFree86 4.x and X.org-X11 support multiple video cards and monitors on one system. This can be handy if you’re testing a new monitor or video card driver. In any event, the Screen section looks something like this: Module Contents

Configuring X11R6 - Setting the Resolution and Color Depth Section “Screen” Identifier “Screen0” Device “Videocard0” Monitor “Monitor0” DefaultDepth 24 SubSection “Display” Depth 24 Modes “1920x1080” “1280x1024” “1024x768” EndSubSection SubSection “Display” Depth 8 Modes “1024x768” “800x600” “640x480” EndSubSection EndSection Module Contents

Configuring X11R6 - Setting the Resolution and Color Depth The Device and Monitor lines refer to the Identifier lines in your Device and Monitor sections, respectively. The Screen section includes one or more Display subsections, which define the video modes that X may use. To choose between the Display subsections, you include a DefaultDepth line. In this example, X uses the 24-bit display if possible, unless it’s overridden by other options when starting X. Module Contents

Configuring X11R6 - Putting It All Together XFree86 4.x and X.org-X11 require a section that’s not present in the XFree86 3.3.6 configuration fi le: ServerLayout. This section links together all the other components of the X confi guration: Section “ServerLayout” Identifier “single head configuration” Screen “Screen0” 0 0 InputDevice “Mouse0” “CorePointer” InputDevice “Keyboard0” “CoreKeyboard” EndSection Module Contents

Configuring X11R6 - Putting It All Together Typically, this section identifies one Screen section and two InputDevice sections (for the keyboard and the mouse). Other configurations are possible, though. For instance, XFree86 4.x and X.org-X11 support multi-head displays, in which multiple monitors are combined to form a larger desktop than either one alone would support. In these configurations, the ServerLayout section includes multiple Screen sections. Module Contents

Setting Fonts and Colours Font technologies can be classified as falling into one of two broad categories: Bitmap Fonts The simplest type of font format is the bitmap font, which represents fonts much like bitmap graphics, in which individual pixels in an array are either active or inactive. Bitmap fonts are fairly easy to manipulate and display, from a programming perspective, which makes them good for low-powered computers. They require potentially dozens of individual fi les for display at different sizes and on different display devices. If you lack the correct font fi le, the result will be an ugly scaled display. Outline Fonts Most modern fonts are distributed as outline fonts (aka scalable fonts). This type of format represents each character as a series of lines and curves in a high-resolution matrix. The computer can scale this representation to any font size or for any display resolution, enabling a single font fi le to handle every possible use of the font. Module Contents

Setting Fonts and Colours For most nowadays Linux distributions there is no need to configure fonts and colours as they come with pretty much correctly configured both, fonts and colours. However, if there was a need to add some new fonts to the system, it would be necessary to locate the X11 font directory (/usr/share/X11/fonts) and use appropriate commands / tools: The mkfontscale program reads all the fonts in the current directory and creates a fonts.scale fi le, which is just like a fonts.dir fi le but describes only outline fonts. The mkfontdir program combines the fonts.scale fi le with the fonts.dir file, creating it if it doesn’t already exist. Both tools are included into the xorg-x11-font-utils package.

Module Contents

Configuring X11R6 - Adding Fonts to X’s Font Path Once you’ve set up fonts in a directory and created a fonts.dir fi le describing them, you must add the fonts to the X font path. You do this by editing the Files section of the XF86Config or xorg.conf fi le: Section “Files” FontPath “/usr/share/fonts/100dpi:unscaled” FontPath “/usr/share/fonts/Type1” FontPath “/usr/share/fonts/truetype” FontPath “/usr/share/fonts/URW” FontPath “/usr/share/fonts/Speedo” FontPath “/usr/share/fonts/100dpi” EndSection Module Contents

Configuring X11R6 - Configuring a Font Server Prior to the release of XFree86 4.0, several Linux distributions began using TrueType-enabled font servers to provide TrueType font support. Most distributions have now abandoned this practice, but some haven’t, and font servers can be useful in some environments. A font server is a handy way to deliver fonts to many computers from a central location. This can be a great time-saver if you want to add fonts to many computers—set them up to use a font server and then tweak that server’s font confi guration. To use a font server, X must list that server in its font path: Section “Files” FontPath “unix:/7100” FontPath “tcp/fount.pangaea.edu:7100” EndSection Module Contents

Configuring X11R6 - Configuring a Font Server The fi rst line in this example specifies a local font server. (Using unix:/- 1 rather than unix:/7100 also works in some cases.) The second line specifi es that the font server on the remote system fount.pangaea.edu is to be used. To add fonts to a font server it will be needed to modify the font server’s configuration fi le, /etc/X11/fs/config. Rather than a series of FontPath lines, as in the main X configuration fi le, the font server’s configuration lists the font path using the catalogue keyword as a comma-delimited list: catalogue = /usr/share/fonts/100dpi:unscaled, /usr/share/fonts/Type1, /usr/share/fonts/truetype, Module Contents

The DISPLAY Variable When an x-application (or X client) is started it needs to know which X server to run on. An X server is referred to as a display. For example the first X server you start (using startx for example) is called ”:0” the second would be called ”:1” and so on. The first X server (or display) running on the host 192.168.1.99 is called 192.168.1.99:0 Most native X clients such as or xclock have a -display switch which can be used to set the display. But the easiest method is to set the environment variable called DISPLAY! xclock -display localhost:0 DISPLAY=localhost:0 xclock Module Contents

The DISPLAY Variable However when using a remote host IP, for example 192.168.1.199, the X server on the host 192.168.1.99 will not allow this x-application to run. The user that started the X server on the remote host (192.168.1.99) needs to run the xhost command. This tool can selectively add or remove hosts to an access control list. Example: Allow remote x-applications from host 192.168.1.7 to run on local server xhost + 192.168.1.7

Module Contents

Starting X An X session can be started using 2 methods: 1. Method 1: From the command line, after logging in onto a virtual terminal the user launches the X Server using a script called startx 2. Method 2: A Display Manager is running prompting the user with a graphical login, this is available for a specific runlevel (on RedHat type distributions this is runlevel 5). Module Contents

Starting X From the Command Line The startx script starts . The xinit script has two main arguments (a) the X server and (b) the xinitrc script. The xinitrc script will source (read) the files Xresourses (controlling the x- applications) and the Xclients (choosing a ). So we can trace the startup sequence as follows: startx --> xinit --> X -> xinitrc -> Xclients Module Contents

Choosing a Window Manager The area that is commonly referred to as the desktop is also known in the X Window world as the screen. It covers the entire area of your monitor display. The is the background of your screen, typically used to display a colour or picture. The window manager provides an interface between the user and the X server. It is virtually impossible to use X without a window manager, because it provides the title bar and the familiar buttons with which you manipulate the display. Module Contents

Choosing a Window Manager The area that is commonly referred to as the desktop is also known in the X Window world as the screen. It covers the entire area of your monitor display. The root window is the background of your screen, typically used to display a colour or picture. The window manager provides an interface between the user and the X server. It is virtually impossible to use X without a window manager, because it provides the title bar and the familiar buttons with which you manipulate the display. Module Contents

Managing GUI Logins Linux can boot into a purely text-based mode in which the console supports text-based logins and text-mode commands. This configuration is suitable for a system that runs as a server computer or for a desktop system for a user who dislikes GUIs. Most desktop users, though, expect their computers to boot into a friendly GUI. For such users, Linux supports a login system that starts X automatically and provides a GUI login screen. Configuring and managing this system requires you to understand a bit of how the system works, how to run it, and how to change the configuration. Module Contents

Managing GUI Logins In addition to the question of whether to run an XDMCP ( Control Protocol) server is the question of which XDMCP server to run. Most distributions set a default XDMCP server in one way or another. Two common methods exist: Selection via Configuration File Some distributions hide the XDMCP server choice in a configuration fi le, often in the /etc/sysconfig directory. In Fedora, the /etc/sysconfig/desktop file sets the DISPLAYMANAGER variable to the path to the executable, as in DISPLAYMANAGER=/bin/xdm. In openSUSE, /etc/sysconfig/displaymanager sets the DISPLAYMANAGER variable to the display manager’s name in lowercase letters, as in DISPLAYMANAGER=”xdm”. Module Contents

Managing GUI Logins Selection via Startup Script In Debian and derivative distributions, such as Ubuntu, the display manager is set via a SysV, Upstart, or systemd startup script—use the gdm script to use GDM, kdm to use KDM, and so on. By default, only one XDMCP server (and associated startup script) is installed, so if you want to change your XDMCP server, you may need to install your desired server. Unfortunately, distribution maintainers have had a habit of changing the details of how XDMCP servers are launched from time to time, and the settings are often buried in poorly documented confi guration fi les. Thus, you may need to go digging through the fi les in your /etc directory to fi nd the correct setting. Module Contents

Choosing a Window Manager In addition to the different window managers there are also various desktop environments, among which the most common are KDE, GNOME and . Below is a brief list of integrated window managers: amiWM mlvwm dfm olvwm mwm Exercise

EXERCISE 6.1 – checking what is your X server 1. Login to your CentOS machine and change the default runlevel to runlevel 3. You can do it either, by editing the /etc/inittabs file (initdefault option) or using command telinit 3. 2. Start your Xwindow system (startx). 3. In the Xwindow system open terminal window and check which is your Xwindow server (ps ax | less). Is it Xorg? Exercise

EXERCISE 6.2 – choosing the default Desktop Manager 1. Leave Xwindow system and check whether there is /etc/sysconfig/dekstop file in your filesystem. 2. Start Xwindow system. Which desktop menager started? GNOME? KDE? 3. If that was GNOME, then leave the Xwindow system. 4. Create /etc/sysconfig/desktop file with the following content: DESKTOP=”KDE” DISPLAYMANAGER=”KDE” 5. Save the /etc/sysconfig/desktop file and start Xwindow system. Which desktop manager started now? 6. Logout from Xwindow system and in the similar way make GNOME the default desktop manager. Exercise

EXERCISE 6.3 – X11R6 configuration file – changing configuration 1. In CentOS check what is the current configuration for the Xorg server. To do so just check /etc/X11/xorg.conf.d directory. Any content there? 2. In the root home directory generate Xorg configuration file (containing current settings for Xorg). This command has to be executed while not in Xwindow system! # Xorg -configure 3. Check if in the root home directory xorg.conf.new file was created. 4. Thoroughly inspect the xorg.conf.new file. Check what the current settings are. 5. Identify the ”Screen” section. 6. Edit the xorg.conf.new file and below the line defining Monitor add a new line: DefaultDepth 8 7. Save the file and copy the file into /etc/X11/xorg.conf.d/xorg.conf file. 8. Sart Xwindow system (startx). What happened? Did it react to the change? 9. Delete the /etc/X11/xorg.conf.d/xorg.conf file! Exercise

EXERCISE 6.4 – Remote X clients ! Both systems should work in Xwindow mode in this exercise! Suppose your local network contains two machines: your CentOS Linux and your Debian Linux. Supose your Debian is a powerful machine that hosts important programs, like a word processor and data analysis utilities. Assume also that CentOS is a much less powerful system, but it has an adequate monitor and keyboard. Therefore, you want to sit at your CentOS machine and run programs that are located on Debian machine. Both systems run Linux. To accomplish this task, follow these steps: Exercise

EXERCISE 6.4 – Remote X clients 1. Log into CentOS machine and, if it’s not already running X, start it. 2. Open a terminal (such as an xterm) on CentOS. 3. Type xhost +Debian_name in CentOS terminal (use your Debian machine name instead of Debian_name, in my case the name is lpic-debian01). This command tells CentOS machine to accept for display in its X server data that originates on Debian machine. 4. Log into Debian machine from CentOS machine. You might use Telnet or Secure (SSH), for instance. The result should be the ability to type commands in a shell on Debian. Exercise

EXERCISE 6.4 – Remote X clients - continues 5. On Debian (within the ssh connection you established), type export DISPLAY=CentOS_name:0.0. (This assumes you’re using bash; if you’re using tcsh, the command is setenv DISPLAY CentOS_name:0.0.). Instead of CentOS_name use your machine name (in my case this is lpic- centos01) This command tells Debian machine to use CentOS for the display of X programs. 6. On your CentOS machine disable SELinux (setenforce 0) and firewall (iptables-save > /root/iptables; iptables --flush). 7. Within the same ssh connection from CentOS to Debian execute any X application, for example xclock. Where did the xclock application window opened? Try with some other ones, like gimp. 8. On your CentOS machine type xhost -Debian_name, then setenforce 1, then iptables-restore < /root/iptables. Exercise

EXERCISE 6.5 – System Settings You will spend next half an hour or so on investigating as to what kind of configuration tools are available in Linux that relate to the Xwindow System. You will need to start KDE and then go to MenuStart- >Applications->Settings->System Settings. There are two tabs there ”General” and ”Advanced”. Try what the tools gathered there do and how they can be used to change system settings.