Chapter 1. Configuring a Desktop Environment

I start the list of annoyances at the desktop, as that's where most new users learn to work with Linux. While most geeks believe in the command-line interface, new users demand an intuitive GUI configured with the applications they need. To add to configuration demands, many organizations demand a standard desktop environment, with a common set of applications, icons, login managers, and so on. Cleaning up every last detail can be annoying for the geek.

In this chapter, I illustrate some of the annoyances related to configuring the desktop environment.

The major question for a Linux user or site administrator, after the selection of a distribution, is which graphical desktop environment to use. While this annoyance focuses on the two major desktops (GNOME and KDE), there are over a dozen other options you can install on the major Linux distributions.

Whatever your choice, you can still take advantage of applications associated with either desktop and other applications that use the X Window System or display their output on a terminal. In this annoyance I show you several ways to integrate KDE applications into a GNOME environment and vice versa.

Each distribution has its preferred desktop. Ubuntu originally went to an extreme, shipping with just GNOME; later the developers created the Kubuntu project to include KDE support. If you choose something other than the preferred desktop in any distribution, expect to do more administration and fix some glitches. Another criterion that can affect your choice is the background of the new user coming to Linux from another operating system. As shown in this annoyance, KDE more closely resembles Microsoft Windows, and GNOME more closely resembles the Apple Macintosh.

While most Linux administrators prefer to configure using the command-line interface, I use GUI tools where possible in this annoyance. This is because when you're configuring a GUI, it's important to be in the GUI to confirm that your changes match your intent.

Some distributions preconfigure applications in the appropriate GNOME menu. For example, when I install the Synaptic Package Manager on a GNOME Debian Linux desktop, it automatically includes a link from the System → System Settings submenu. But while it is less friendly to KDE applications, you can still include them in the GNOME menu. I'll show you how you can configure them on a single computer using the GUI, and then how to tweak a configuration file, a solution you can automate through a script and therefore share with a large number of users on your network.

As this section shows, it's easy to change menus by editing the configuration files for each user. But this flexibility contains its own annoyance for site administrators, because it means all users can edit their own GUI menus. That may be a problem for managers who want a standard GUI desktop. If you want to freeze your users' menu configurations, see the "My Users Mess Up Their Desktops" annoyance later in this chapter.

If possible, I recommend that you use the Simple Menu Editor for GNOME (SMEG). It is easy to use. But as of this writing, none of the distributions that we examine in this book use SMEG. (However, it is available as part of the alacarte RPM in the Fedora Extras repository.)

Alternatively, you can start the Nautilus File Browser and then open a window that specifies the applications in the main menu. For the purposes of this example, I'll add the KOffice Write application under the Office submenu. To do so, take the following steps, which apply to older versions of GNOME (=< 2.8) associated with active distributions such as Red Hat Enterprise Linux 3 and 4:

  1. In a command line in a GUI desktop, run the nautilus command. This opens the Nautilus browser.

  2. Press Ctrl-L. In the Location text box, navigate to applications:///. This opens the Applications window. Compare the entries to what you see in your Applications menu. They should be nearly identical. My version is shown in Figure 1-3.

  3. Use the Office icon to open a window that shows the current items in the Office submenu. Right-click in the menu and select Create Launcher from the pop-up menu.

  4. In the Create Launcher window, enter the information associated with the application. In this example, to add the KOffice Word application, in the Name text box, enter KOffice Word, which is what gets shown in the Applications submenu.

  5. In the Comment text box, enter a name that will be shown when the user hovers the pointer over the menu item.

  6. In the Command text box, enter the complete path, /usr/bin/kword.

    If you can't find the complete path to your desired application, the locate command can help. For more information, see the "I Don't Remember Where That File Is" annoyance in Chapter 2. If you know the name of the file, the dpkg -S packagename or rpm -ql packagename commands list all files installed from the package.

  7. Click Icon to see options for icons you can link to this entry. Alternatively, click Browse to find the icon you prefer.

  8. When you click OK to exit from the Create Launcher window, the item is added to the menu and is ready for use.

While Linux distributions preconfigure many GNOME applications under the appropriate KDE menus, you'll need to do more to complete the job. Not all applications are picked up by the KDE desktop. KDE may even miss some that are not GNOME-specific applications.

For this example, I decided to include the XWhois application under the KDE Internet submenu. To do so, take the following steps:

  1. As a regular user, run the kmenuedit command. This opens the KDE Menu Editor shown in Figure 1-4.

    If you encounter an error message, such as failed to create /home/michael/.config/menus/, you may already have a .config file in your home directory. You'll have to move it. If you see an error message such as kmenuedit: WARNING: Could not read /home/michael/.config/menus/applications-kmenuedit.menu, which tends to appear the first time someone uses the KDE Menu Editor on a given desktop, ignore the message.

  2. Note how the lefthand pane matches what you see when you click the K Menu button in the lower-left corner of your desktop.

  3. Highlight the submenu of your choice—in this case, the Internet menu.

  4. Click File → New Item. This opens the New Item window, where you can enter the name you want to see in the K Menu. Here, I use XWhois. Click OK.

  5. Back in the Menu Editor, you'll see the Internet submenu open, with the new entry. You can now add a Description and Comment of your choice in the respective text boxes.

  6. In the Command text box, enter the path to the application. In this case, on Debian Linux, it's /usr/bin/xwhois.

  7. If you want an icon for this application, click on the icon to the right of the Name and Description text boxes. This opens a list of icons in the /usr/share/icons subdirectory. (The actual icon files may be deep in this sudirectory.) I've used an icon that came with the xwhois package.

  8. When you're done, click File → Save and then File → Quit. KDE saves the changes to the applications-kmenuedit.menu file associated with the error message described in step 1.

One thing many managers like is consistency. In many organizations, that starts with what everyone sees at the beginning of the day, the login menu. In this annoyance, I'll show you how you can customize and standardize the GNOME and KDE login menus. But first, you need to select a standard login manager for your workstations.

Whether you want to use GNOME, KDE, or another GUI desktop, you need to select your preferred login manager. Even if you're running GNOME desktops, you can still use the KDE login manager, and visa versa. Each of the book's preferred distributions allows you to select the preferred login manager in a configuration file specific to that distribution, as described in Table 1-1.

As you review what each login manager can do in this annoyance, you may change your mind on what's best. You can always return to this section and configure a different preferred login manager for your systems. If you're configuring a standard across many users' computers, you'll have to copy the appropriate file to the other systems that you administer.

Before you start editing the GNOME Login Menu, back up the defaults in the GNOME configuration directory. The location of this directory varies by distribution. As of this writing, it is:

As distributions evolve, these directories may change. To find the directory on your distribution, run one of the following commands:

rpm -ql gdm | grep gdm.conf
dpkg -L gdm | grep gdm.conf

If you get no output, either you haven't installed the GNOME Login Menu package or the name of the directory has changed.

The standard tool to edit the GNOME Login Menu is the Login Screen Setup tool, which you can start with the gdmsetup command. This opens the Login Screen Setup window shown in Figure 1-5. I'll examine each of the tabs in turn.

The General tab defines the basic settings associated with the GNOME Display Manager login screen and allows you to configure several options, which are described in Table 1-2. Be aware that SUSE Linux Professional enables automatic logins by default. This is all right for a system dedicated to a single user in an environment, such as laptop or home office, where intruders are not expected to meddle with it. It also is a good choice for a locked-down public terminal offering a guest account. It should be disabled otherwise.

The X Display Manager Control Protocol (XDMCP) supports logins to remote GUI systems. As you can see from the XDMCP tab, there are several ways you can configure this protocol if you want to allow remote users to log in to your system using the GNOME Display Manager, as described in Table 1-4.

Before you start editing the KDE Login Manager, back up the defaults in the KDE configuration directory. The location of this directory varies by distribution. As of this writing, it is:

In any case, the key file is kdmrc , which you can edit directly.

Alternatively, you can start the KDE Login Manager editing tool from the KDE Control Center. Navigate to System Administration → Login Manager. You can also run the kcmshell kdm command. Either action opens the Login Screen Setup window shown in Figure 1-6. I'll examine each of the tabs in turn.

I define a standard desktop as one with a consistent look and feel after login. It's consistent for all users, at least before individual users customize their desktop environments.

In general, desktop settings are the sum of their parts. Both KDE and GNOME have standard desktop environments, defined in specific directories, such as /etc/kde3 or /opt/gnome/share, as well as hidden directories associated with specific users, such as ~/.kde/share.

If you want a standard desktop, you need consistency with respect to the following:

I address some of the other components of a standard desktop (desktop resolution, a consistent program menu, a standard menu bar, a custom login screen, and a uniform group of icons) in different annoyances. In this annoyance, I show you how to configure a consistent background and screensaver for a KDE and a GNOME desktop environment.

One benchmark in a consistent organizational image is what people see when they walk through your offices. Everyone has different items on their desks, such as family photos, personal souvenirs, etc. However, almost everyone has a computer with a monitor.

Personally, I think people should be able to put what they want (with the possible exception of obscene words and pictures) on their monitor desktops and screensavers at work. But your manager and/or company may think differently. They might tell you that what visitors (and his bosses) see on everyone's GUI desktop background and screensaver should look and feel professional, as it affects their opinion of your organization.

The foundation of a consistent look and feel on the desktop is a consistent background. Assuming you use one of the two standard Linux desktop environments, you can configure it through the KDE Control Center or the GNOME desktop background applet.

In a secure environment, you may not want customers or visiting rivals (or anyone who might be considered a security risk) to see what your users are doing. When your users leave their workstations temporarily, they often don't shut down their computers. With password protection on their screensavers, you can help protect any critical or confidential information.

In addition, screensavers are one more opportunity to set up a consistent look and feel in your office environment.

The GNOME desktop environment takes advantage of a group of standard screensavers available to all Linux systems, part of the xscreensaver package. The configuration tool is xscreensaver-demo, which is in either /usr/bin (SUSE, Fedora, and Debian) or /usr/X11R6/bin (Red Hat Enterprise Linux). This opens the Screensaver Preferences window.

There are a substantial number of things you can configure in the Screensaver Preferences window. I'll focus on only those two items critical to your system security:

Once you select a screensaver and close the utility, the configuration is saved in the ~/.xscreensaver configuration file, which you can copy to each of your users' home directories.

Before any changes take effect, you'll need to restart the xscreensaver daemon (it's not a standard daemon, as it doesn't have a start script in the /etc/init.d directory). The easiest way to restart it is from the xscreensaver-demo utility; click File → Restart Daemon. Alternatively, you can restart the daemon from the command line. First, find the Process Identifier (PID) associated with the xscreensaver daemon with the following command:

ps aux | grep xscreensaver

The PID is the number in the second column. For example, if the PID is 1111, you can restart the daemon with the following command:

kill -hup 1111

Creating and locking GUI desktop icons is a straightforward process and is one more thing that you can do to configure a consistent look and feel for the GUI desktops in your office. In general, the easiest way to lock the icons on the desktop is by assigning appropriate ownership on the ~/Desktop directory. What you do may vary slightly if you're using the KDE Desktop Environment or SUSE Linux Professional.

You can easily configure a standard set of desktop icons for the KDE Desktop Environment either within the GUI or from the command line. To use the GUI, right-click on the desktop and select Create New → File → Link to Application. You can then create the desktop icon that you need from the properties menu that appears.

To create a desktop icon from the command-line interface, use a procedure such as the following. Essentially, you will use an existing text file that configures a desktop application as the model for one customized for your new application. For this example, I added a desktop icon for the OpenOffice.org Writer as follows:

Once you're satisfied with your icons, add the following to the kdesktoprc configuration file:

[KDE Action Restrictions][$i]
editable_desktop_icons=false

The location of kdesktoprc varies by distribution. On Red Hat/Fedora, it's in /usr/share/config; on SUSE, it's in /opt/kde3/share/config; on Debian, it's in /etc/kde3. Once configured, all you need to do is copy this file to other servers that contain your user's home directories. Alternatively, you can use the individual configuration directory for each user, which happens to be consistent for all three distributions: ~/.kde/share/config/kdesktoprc.

Whatever your selection, check the result. The next time you start the KDE Desktop, right-click on the screen. Notice how the pop-up menu has changed. Right-click on an icon. See how that pop-up menu has changed. If you made the change of ownership recommended in the procedure, you won't be able to use the Create New option. Generally, all you can do once you've made this change is click on the icon to open the associated application, directory, or linked file.

For more information on restricting actions on KDE, see the "My Users Mess Up Their Desktops" annoyance.

As with KDE, you can configure a standard set of desktop icons for the GNOME desktop environment through its GUI. For example, I added a desktop icon for OpenOffice.org Writer with the following steps:

  1. In the GNOME desktop environment, I right-clicked on the desktop. In the pop-up menu that appeared, I clicked Create Launcher to open the Create Launcher window.

  2. In the Name text box, I entered OpenOffice.org Writer, which is the name I want to see on the desktop.

  3. In the Comment text box, I added a simple description—in this case, The OpenOffice.org Word Processor.

  4. In the Command text box, I added the full path to the command that starts the OpenOffice.org Writer—in this case, /usr/bin/oowriter.

  5. I didn't change the type, as this word processor is an application. However, I could have set the type to a directory, a link, or a filesystem device (FSDevice) for directories mounted on specific devices. The other options in this drop-down box are not used.

  6. Now it was time to configure this launcher with an icon to be shown on the desktop. I know that there's an ooo_writer.png icon available from the openoffice.org package. So I clicked on the icon and navigated to the associated location. When successful, the icon is shown in the Create Launcher window.

  7. If I were configuring a command-line application such as the vim editor, I'd want to run it in a terminal. However, that's not appropriate for a GUI application such as OpenOffice.org Writer.

  8. I clicked OK and saw the OpenOffice.org Writer icon appear on my desktop. I can click on this icon to open the word processor.

  9. I continued creating any more icons that I need.

  10. Once complete, I froze the configuration. I changed the permissions on the files in the ~/Desktop/ directory with the following command (my home directory is /home/michael):

    chmod 400 /home/michael/Desktop/*

    And then I changed ownership on the ~/Desktop/ directory. The following command takes ownership, and the ability to change any files contained within, from any regular user.

    chown root.root /home/michael/Desktop

    Now, if I try deleting any icon, I get an error message. While users can still right-click to change permissions, this helps preserve a standard desktop. Other issues are discussed in the following section.

  11. Then I wanted to add the same icons to other users' desktops on this server. I could do so with a command similar to:

    find /home/*/Desktop -maxdepth 0 -exec cp /home/michael/Desktop/* '{}' ';'

    This command copies all files, but no directories, from /home/michael/Desktop to every user's Desktop/ subdirectory.

  12. I also needed to change the ownership and permissions of each user's Desktop/ subdirectory, as I did with my own. Fortunately, that command is simpler; all I needed was the proper wildcard to make sure ownership and permissions were changed on the ~/Desktop directory of all users (the -R ensures that the changes are made recursively through Desktop/ subdirectories):

    chown -R root.root /home/*/Desktop
    chmod -R 770 /home/*/Desktop
  13. For future users, I copied the contents of my personal Desktop/ subdirectory to /etc/skel, so all new users get the same subdirectory.

    cp -a /home/michael/Desktop /etc/skel/
  14. Finally, I applied the chown command to the Desktop/ subdirectory to make sure icons aren't changed by new users.

I'm nearsighted, so I don't fully appreciate the focus on higher dot pitches on the latest monitors. Yes, more dots do mean a higher level of resolution, which is important in many applications. If you're working on something with a lot of detail, such as an airplane drawing, you need to see those little details, such as those parts that might interfere with one other.

However, as I type this chapter, I much prefer bigger letters. I use a resolution of 800 × 600 on my 15" laptop screen. While I could increase font sizes on a higher-resolution screen, that means additional work to customize applications, desktop icons, and more.

You can configure the resolution directly in the associated X configuration file. But even most Linux geeks use tools to help. In this annoyance, I'll show you how you can use the standard X Window tool, as well as the graphical tools from Red Hat/Fedora, SUSE, and Debian. I'll also show you how to use the GNOME and KDE display tools, which allow individuals to modify the display resolution on their workstations.

With the exception of the GNOME and KDE display tools, all the tools in this annoyance require root account privileges. While you can disable the GNOME and KDE display tools, I recommend against it. After all, people work more efficiently with screens set to the resolution that is most comfortable for their eyes. However, if you do want to disable those tools for individual users, use the techniques described in the "My Users Mess Up Their Desktops" annoyance in this chapter.

You can configure your GUI from the command-line interface. While it can be difficult, a Linux expert like yourself should know the basics, at least to know if the tool that you've used has caused problems with your configuration. If you aren't confident in your distribution's graphical tool, you can invoke the command-line tool with the xf86config command.

Because of licensing issues, most Linux distributions have recently converted from the XFree86 to the X.org GUI server. Others, such as SUSE, use the standard X.org configuration filename /etc/X11/xorg.conf. This also affects the associated utilities; for example, the xf86config and xf86cfg utilities may be known by new names, such as xorgconfig and xorgcfg. While Red Hat Enterprise Linux 4 still uses XF86Config, in the /etc/X11 directory, Fedora and Debian have recently made the switch as well.

If you're more familiar with the XFree86 configuration files, don't worry. Whatever configuration file you see in the /etc/X11/ directory, the format of the file remains the same.

Before you change any configuration file, you should back it up in a secure location such as your home directory. Many tools do back up the X configuration file. So if you make a mistake, you may be able to restore your original configuration from a file with a name such as /etc/X11/XF86Config-4.bak. However, if you make a mistake and then use the same tool again, you'll overwrite the automatic backup. So it's best to keep a working backup of the X configuration file in your home directory; then you won't be out of luck.

As described earlier, xf86config and xorgconfig are two names for the same utility, and the name depends on whether you're using the XFree86 or X.org servers. (The GUI versions of this utility are xf86cfg and xorgcfg, respectively.) If this utility is not available on your distribution, you should be able to install the RPM or DEB package of the same or similar name. On Debian Linux, the associated package is xbase-clients; on SUSE Linux, the package is xorg-x11.

When you start the xorgconfig or xf86config utility, you'll see a warning that you need to know your video card, the amount of video memory, and the associated chipset. If you don't have this information (or if you have a problem with any of the other queries), you can press Ctrl-C to abort the utility before writing a new X configuration file. Otherwise, to run this utility, use the following steps:

  1. Run the xorgconfig (or for XFree86 servers, the xf86config) command. Read the associated warning. Assuming you know your video card, memory, and associated chipset, continue to the next step.

  2. Specify the protocol most appropriate for your mouse or pointing device. The latest versions of this utility support auto-detection. Accept auto-detection (option 1 when auto-detection is available) or enter the number associated with the protocol.

  3. If you specified a mouse-related protocol and have a two-button mouse, you can now support emulation of a third button (pressing the left and right buttons simultaneously produces the same effect as pressing the middle button on a three-button mouse). As described in "My Mouse Doesn't Do What I Want," later in this chapter, the third mouse button lets you do more in some GUI desktop environments.

    Option     "Emulate3Buttons"      "true"
  4. Now, specify the device associated with the mouse. The default, /dev/mouse, is sufficient if it is already linked to the actual mouse device. To confirm, go to another text console and run the ls -l /dev/mouse command. If you don't see a link, you should either specify the right device for your mouse in this step or accept the default and create a symbolic link to the right device yourself.

  5. Next, select the keyboard most closely related to what you have. If you don't see your keyboard at first, press Enter without making a selection. The utility scrolls through the available options.

  6. In the following step, you can specify a language associated with your keyboard. As before, if you press Enter without making a selection, the utility scrolls through the available options.

  7. Now enter the name of your choice. The name becomes associated with the XkbVariant directive in the configuration file.

    There are additional keyboard options available in the next step; some are language-dependent.

  8. Read carefully when you see the note about monitor specifications. If you don't know the specs for your monitor, check your documentation. If it isn't readily available, you may see reference to a monitor database file, which can help. Incorrect settings can damage the monitor.

  9. Enter the horizontal sync range and allowable resolution of your monitor. Several preconfigured selections are available. Whatever you select here and in the next step must be within the limits specified in your monitor documentation.

  10. Enter the vertical refresh rate of the monitor.

  11. At the note associated with video card specifications, type y and hit Enter to check out the available database of graphical cards. If you can't find yours among the 500+ available in the database, you may select an option such as "Generic VESA compatible," which is also known as Super VGA.

  12. Select the amount of video memory available for your card.

  13. Enter a name of your choice. The name becomes associated with the Identifer of your video card in the configuration file.

    Based on the video card, monitor, and memory, the utility now calculates possible video modes, also known as resolutions. Review them and make any changes if needed.

  14. Specify the default color depth. Generally, 24 or 32 bits is best, unless you have a limited amount of video memory—less than 8 MB—or a monitor that can handle only the simplest color modes.

  15. Finally, specify the name for your configuration file. By default, the utility overwrites the current X Window configuration file; however, if you're just experimenting with options, you can specify the filename of your choice.

Linux offers additional graphical X Configuration tools. As it's one way distributions distinguish themselves, you may find different GUI tools available on each distribution that you try.

As each of these tools is elementary for the geek, I'll just briefly describe the tools available for the major distributions covered in this book.

The mouse (or pointing device, such as a touchpad) is important to users on any graphical desktop environment. Each button has its function. Left-handed users often find it helpful to switch the functionality of the left and right buttons. All users may want to customize the size of the cursor, as well as the speed of motion. Many users may have problems with the scroll wheel.

The middle mouse button is important for some users. It activates a pop-up menu in the KDE desktop environment, and it pastes recently highlighted text into editors and the command-line interface.

But most PC-based pointing devices, including mice, have only two buttons—or it might just seem that way. In many cases, you can configure a middle mouse button using the appropriate X Window configuration tool; I've described several in the previous annoyance and won't describe their uses here.

You may be able to configure what you need with the GNOME Mouse Preferences tool or the KDE Configure - Mouse tool. If you need to do more, such as configure a scroll wheel or touchpad, you may need to modify your X Window configuration file directly. I illustrate how to help you meet both needs in this annoyance.

When you're in an application with a long array of data, such as a 30-page document or a big web page, you can often use the scroll wheel to move up and down the document. The scroll wheel is usually a wheel in the center of a mouse. Virtual scroll wheels are also offered by some touchpads. In many cases, if you move your finger up and down the right quarter of the touchpad, the effect is the same as that of a scroll wheel.

Linux may have already configured your scroll wheel when it detected your mouse. If so, you should have no problems using your scroll wheel.

However, the configuration of a virtual scroll wheel on a touchpad is a more difficult exercise. I illustrate the necessary changes to the xorg.conf file here using the working configuration from my SUSE workstation on a Sony laptop. The same settings work well on my Debian workstation on an HP laptop, with a couple of modifications:

Section "InputDevice"
  Driver       "synaptics"
  Identifier   "Mouse[2]"
  Option       "Device" "/dev/input/mice"
  Option       "Emulate3Buttons" "on"
  Option       "InputFashion" "Mouse"
  Option       "Name" "Synaptics;Touchpad"
  Option       "Protocol" "explorerps/2"
  Option       "SHMConfig" "on"
  Option       "Vendor" "Sysp"
  Option       "ZAxisMapping" "4 5"
EndSection

These directives may not work for your touchpad. If you have a touchpad on a laptop computer, you may be able to benefit from the experience of others. Search for the name of your laptop computer online. Alternatively, search for your laptop on a web site such as http://www.linux-laptop.net.

Now, I'll explain each of these directives in Table 1-7. The first and last directives are straightforward; they bracket the stanza. All mice, touchpads, other pointing devices, and even keyboards are known as the InputDevice directive.

Configuration data for other types of pointing devices is available in the README.mouse file, typically available in the /usr/X11R6/lib/X11/doc directory. It includes configuration information for an alternative touchpad, the Alps GlidePoint.

If this configuration doesn't work for you, make sure you've inserted the names of the appropriate drivers into a file such as /etc/modprobe.conf, /etc/modules.conf, or /etc/modprobe.d/mouse.

You may want to customize your touchpad further. While there is no dedicated HOWTO or FAQ that explains the directives that you can use, there is hard-won experience available from other Linux users on web sites such as http://tuxmobil.org. They include directives such as LeftEdge, RightEdge, TopEdge, BottomEdge, FingerLow, FingerHigh, MaxTapTime, MaxTapMove, VertScrollDelta, MinSpeed, MaxSpeed, EdgeMotionSpeed, and AccelFactor.

Some trial and error may be required, so remember to back up your X Window configuration file before you start editing!

Once you've made all of these changes, you may want to keep your users from messing them up. While I personally prefer allowing every user to customize his system, your managers may not agree.

There are two basic approaches to this process. First, you can disable access to the key tools. Second, you can change ownership and permissions on associated configuration files to prevent changes by regular users.

You can also make your changes a part of the /etc/skel directory, which causes them to be copied into the home directories of all users created subsequently. For example, the following command creates the new user nancy; the -m option (not required on Red Hat/Fedora) creates Nancy's home directory in /home/nancy, and activates the defaults in /etc/default/useradd, copying the files from /etc/skel,with appropriate ownership and permissions, into Nancy's home directory:

useradd -m nancy

The KDE desktop environment includes a number of options suitable for kiosks, which are common locations for public terminals. If you administer a public terminal, you'll probably want to freeze the desktop configuration of that terminal. What you do for workstations in an office may also incorporate some of the same limitations.

In the previous section, I've covered some of the things you can do to disable configuration changes. You can also restrict such actions as starting a command-line interface, running as the root user, or changing the background. Open a kdeglobals configuration file and start a stanza with the following title:

[KDE Action Restrictions][$i]

On a workstation, you may want to keep certain users away from the command-line interface. You can do so in this stanza with the following directive:

shell_access=false

By default, users can also start applications from the Run Application window, invoked through Alt-F2. If you want to disable access to this window, add the following directive:

run_command=false

You can keep users from using any KDE utilities that require the root account with a directive such as:

user/root=false

But users don't need the root account to customize many things on the KDE desktop. You can further limit access to different modules in the KDE Control Center, in a different stanza, starting with:

[KDE Control Module Restrictions][$i]

Here, you can limit access to the modules of your choice. For example, if you want to keep users from changing their own KDE desktop backgrounds, add the following directive to this stanza:

kde-background.desktop=false

To keep your users from changing their screensavers, include the following directive:

kde-screensaver.desktop=false

If you want to limit access to another module, you simply need to know the name, as defined in the output from the following command:

kcmshell --list

Then, to limit access to the module of your choice, just substitute the name of that module in the following directive:

kde-module name.desktop=false

The key to a standard GNOME desktop environment is the GConf system. Readers familiar with Microsoft Windows might notice parallels to the Registry Editor. You can start the GConf editor with the gconf-editor command (normally, it's in the /usr/bin directory; on SUSE, it's in the /opt/gnome/bin directory). There are three types of GNOME settings. What each user sees is an amalgamation of these:

Sometimes the easiest way to keep users from changing their standard desktop environments is to disable the GUI menu items. In other words, if the user doesn't see the administrative tool, he's less likely to want to try to use it.

Default GNOME main-menu files are located in the /usr/share/applications directory. User-specific menu files are located in each user's home directory, in ~/.config/menus. Managing the GNOME menu items is a straightforward process; for example, if your SUSE Linux computers are configured with the GNOME Desktop Environment, and you want to disable GNOME menu-based access to the YaST configuration tool, move (don't delete) the YaST.desktop file from the /usr/share/applications directory. (I move it to my home directory, in case I ever want to restore the menu option.)

If you're already in the GNOME Desktop Environment, check your menu. The changes are shown immediately on the Red Hat/Fedora and Debian distributions. The changes aren't shown on SUSE Linux until the next time you start GNOME.

Now you can implement these changes to the other desktop systems on your network. Remember, if you're removing items from the GNOME desktop menus, you'll have to remove the corresponding items from the /usr/share/applications directory on each of your target systems.

When you press the eject button on your CD or DVD drive, you'd think that the drive should open. Unfortunately, it doesn't always happen. Anything that is using a file or reading a directory on that CD/DVD can keep your system from opening that drive. This could be something as simple as a user whose current directory lies on the CD/DVD drive.

If you're running Linux as a server, you probably need to accept the locking of the CD/DVD drive. Other users may be installing Linux from a shared DVD on your system and may need access to the data on the drive. While you may have good reasons as an administrator to unlock a drive, be aware that you may be interrupting some task being run by one or more of your users (or fellow administrators).

On the other hand, if you're working with a single-user Linux workstation, users won't understand why their CD/DVD is locked. They'll just complain, and you'll be annoyed, as they won't be interested in learning "simple" commands such as umount. All they'll tell you is that the CD is broken.

In this annoyance, I'll show you how I believe servers and workstations should be configured with respect to the CD/DVD drive. The defaults vary depending on your distribution. Based on those defaults, if you still have problems, there are a series of common steps that you can follow.

When you configure a server, you'll want full control over any CD/DVD drives on your system. Generally, you'll want to limit privileges to administrative users. Take the following default entry from my /etc/fstab on Red Hat Enterprise Linux 4, with a regular CD/DVD drive:

/dev/hdc  /media/cdrecorder  auto  pamconsole,exec,noauto,managed 0 0

The applicable entry from my SUSE Linux workstation is:

/dev/cdrecorder  /media/cdrecorder  subfs  noauto,users,gid=users 0 0

Finally, the associated directive from my Debian system is:

/dev/hdc  /media/cdrecorder  auto  ro,users,noauto,unhide,exec 0 0

As you should already know, the first column is the CD/DVD drive device file, and the second column is the default directory where the drive is mounted. The third column specifies the filesystem, such as ext3 or reiserfs. auto auto-detects the filesystem. subfs represents the Linux removable-media-handling system and is most closely associated with SUSE. The fourth column specifies the mount options, and that's the focus for this annoyance. (For more information on the fifth and sixth columns, which are rarely changed these days, see the fstab manpage.) Examine the options described in Table 1-9. This table is not comprehensive, but is limited to options that may contribute to problems unmounting a CD/DVD drive.

With these options in mind, I recommend that you change the directives associated with the CD/DVD drive in your /etc/fstab to disallow mounts by regular users. I'd change the SUSE Linux 9.3 directive to delete users access by user and group:

/dev/cdrecorder  /media/cdrecorder  subfs  noauto 0 0

I'd change the Debian Sarge directive to delete regular user access by removing the users and uid options.

/dev/hdc  /media/cdrecorder  auto  ro,noauto,unhide,exec 0 0

The situation with Red Hat Enterprise Linux 4/Fedora Core is different. The directive associated with the CD/DVD drive is governed by the relatively new Hardware Abstraction Layer daemon, using the storage-policy.fdi configuration file. On Fedora Core, this file is located in the /usr/share/hal/fdi/90systempolicy/ subdirectory; on Red Hat Enterprise Linux 4, it's located in the /usr/share/hal/fdi/90defaultpolicy/ directory.

By default, the user who owns the device file associated with the CD/DVD drive can also mount and unmount that drive. In other words, based on the following, the user michael, and no other regular user, is allowed to mount the CD/DVD drive associated with /dev/hdd:

$ ls -l /dev/hdd
brw------- 1 michael disk 22, 64 Jul 22 02:35 /dev/hdd

If the specified user is your regular account as an administrator, that's generally good enough for a server.

As an alternative to changing fstab, you can remove the following line from the noted storage-policy.fdi configuration file:

<merge key="storage.policy.default.mount_option.pamconsole" type="bool">true</merge>

When you restart the HAL daemon with the /etc/init.d/haldaemon restart command, not even the regular owner of the CD/DVD device file is allowed to mount that drive. Access is limited to the root user, and that's appropriate on a server.

Workstations should be configured differently from servers. One difference is in the way they handle removable media. Regular users expect CDs and DVDs to be automatically mounted when placed in their drives.

It's important that the applicable directives in /etc/fstab support access by normal users. Based on the directives from the previous section, I'd make sure at least the user option is included in the appropriate directive; the following example works on my SUSE Professional workstation:

/dev/cdrecorder  /media/cdrecorder  subfs  noauto,users,gid=users 0 0

The following works well on a Debian Sarge workstation:

/dev/hdc  /media/cdrecorder  auto  ro,users,noauto,unhide,exec 0 0

The situation is a bit different with Red Hat/Fedora workstations. The directive is acceptable as is; all you need to do is make sure the owner of the CD/DVD device file, such as /dev/hdc or /dev/hdd, is the primary user of the workstation.

GNOME provides removable device-management tools that are not affected by the options in /etc/fstab. For example, in the GNOME Desktop Environment, run the gnome-volume-properties command. This starts the Drives and Media Preferences tool, which allows you to control how GNOME reacts when you insert a CD/DVD into the drive. On a server, I recommend that you disable all automatic mounting.

There is no corresponding stable utility available on the KDE Desktop Environment; the last information I can find on the Kautorun software is from 2000. However, you can take advantage of the .kde/Autostart directory to create your own Autorun system on KDE. The Autorun system is available only on Red Hat distributions. The associated RPM doesn't work on SUSE Linux, so if you want Autorun on KDE for SUSE or Debian Linux, you'll have to compile it from the source code. To do so, take the following steps:

  1. Download the latest source package from the Autorun project web site at http://sourceforge.net/projects/autorun/.

  2. Unpack the package. For this example, I've downloaded it to my /home/michael directory, so I've run the following commands (substitute the version number for versionnum):

    cd /home/michael
    tar xzvf autorun-versionnum.tar.gz
  3. Navigate to the directory that's created; it's the autorun- versionnum subdirectory:

    cd autorun-versionnum
  4. Configure the source code; the local configure file is already set up as a script for this purpose:

    ./configure

    Address any errors that may arise during the configuration process. I did not find any errors when I ran this command on my SUSE and Debian Linux workstations.

  5. Run the following command as the root user (to make sure you have permissions and PATH access to appropriate directories) to compile the code:

    make

    You may get errors at this point because of other packages that you may need to install. Some educated guesses may be required. For example, on my Debian workstation, I installed the libxml-parser-perl package because of the following error message:

    checking for XML::Parser... configure: error: XML::Parser perl module is required for
    intltool

    Some error messages are simpler; the following from my SUSE workstation led me to install the xmlto RPM (and several dependencies):

    make[2]: xmlto: Command not found
  6. Run the following command to install the compiled packages in appropriate locations:

    make install

    Pay attention to the final messages, which list the location of the Autorun.desktop script.

  7. Copy the Autorun.desktop script to an appropriate location on desired users' home directories, and, if necessary, make sure ownership is appropriate:

    cp /usr/local/share/autorun/Autorun.desktop /home/michael/.kde/Autostart/
    chown michael.users /home/michael/.kde/Autostart/Autorun.desktop
  8. Update the Autorun.desktop script to point to the actual location of the autorun command; when I compiled from source, it was copied to the /usr/local/bin directory. The next time you start KDE, it will automatically look for and mount any drive in your CD/DVD drive.

Remember to tell your users how they can unmount their drives—at least how they can right-click on the CD/DVD icon in their GUI desktops to bring up a menu that lets them unmount the drive. I describe this and other options in the next section.

As problems with a CD/DVD drive can vary, I provide a simple checklist of steps you can take. The first steps may seem elementary for geeks but are shown because we all forget the obvious sometimes:

  1. If you're in the GUI, you may see an icon related to the CD/DVD drive. Right-click on it; on the menu that appears, you'll probably have an option such as "eject" or "umount." Click on the available option (if both are available, try "eject" first).

    You may get an error message to the effect that the mounted volume is not in /etc/fstab (especially if you're not the root user). In that case, proceed to the next step.

  2. Check to see if your CD/DVD drive is mounted. You can do so with the mount command (by itself). If you're not sure how your CD/DVD drive is mounted, check your /etc/fstab and /etc/auto.misc configuration files for clues.

    It's certainly possible for another administrator to mount your CD/DVD drive on a different directory, which should show up in the output to the mount command.

    You can get a more complete list of mounted devices from the /proc/mounts file.

  3. If your drive is mounted on a directory defined by /etc/fstab (or another directory shown in the output from mount), try ejecting it. For example, if it's mounted on /media/cdrecorder, try the following command:

    eject /media/cdrecorder

    If your drive is automounted as configured in /etc/auto.misc, the eject command may not work. But after there's been no activity for a timeout defined in /etc/auto.master, the automounter automatically unmounts the drive.

    If you get an error message such as:

    umount: /media/cdrecorder: device is busy

    you know that some process, local or remote, is trying to read the device. Before you unmount the CD/DVD, you'll need to somehow stop the process. Proceed to the next step.

  4. Try unmounting the drive in question with a command such as the following. Remember, the umount command is spelled differently from the English-language word:

    umount /media/cdrecorder

    You can substitute the device to be unmounted. You may get an error message such as that described in the previous step. Otherwise, try pressing the button on your drive to see whether you can manually eject the disk.

  5. If you're still having problems unmounting the drive, you should now try to identify the process that's reading the drive. That's where the list-open-files (lsof) command can help. It even shows files shared via Samba; for example, the following output from the lsof +D /media/cdrecorder command points to a remote user accessing your CD via Samba (the +D switch is key; without it, the command doesn't know where to start looking):

    COMMAND  PID    USER   FD   TYPE DEVICE SIZE NODE NAME
    smbd    4812 michael  cwd    DIR  22,64 2048 1856 /media/cdrecorder

    The limitation of the lsof command is that it can't help you with files opened via a shared NFS directory.

  6. If you've shared your CD/DVD via Samba, you can check if anyone has accessed any of your Samba shares with the smbstatus command.

  7. If you've shared your CD/DVD via NFS, checking access is more problematic. The showmount -a command, in concert with the shares defined in /etc/exports, can only help you define the workstations that have accessed shares from your NFS server.

  8. If there are current users on other workstations using your CD/DVD, warn them. You may need to use other means, such as Instant Messaging, to warn them that you're about to cut off all processes that access the CD/DVD. Then issue the following command as root:

    fuser -km /media/cdrecorder

Sometimes the GUI just won't start. You've configured your /etc/inittab to boot Linux in a runlevel associated with the GUI. You may see a command-line login prompt for a very few seconds. You may get to a GUI Login Manager and enter the correct username and password, and the GUI Login Manager just reappears.

There are several possible causes of this failure:

In this annoyance, I limit coverage to the most popular desktop environments, KDE and GNOME.

If you can't start the GUI, you might have forgotten to install the associated packages. You could navigate to the package-management tool of your choice, but for Red Hat and Fedora's system-config-packages or pirut, that requires the GUI. If all you're familiar with on Debian is the Synaptic package manager, that requires the GUI. SUSE's YaST won't work if the /tmp directory is completely deleted. I'll describe what you can do in each of these cases.

When you configure a desktop for ordinary users, you'll generally want to let them log directly in to the GUI. The "I Need a Custom Login Menu" annoyance, earlier in this chapter, illustrates how you can create a custom GUI login menu. You'll also need to make sure the boot system, as defined in /etc/inittab, starts you in a runlevel appropriate for the GUI.

Assuming you've installed the appropriate GUI login manager, open the /etc/inittab file in a text editor. Inspect the line with the id directive. If you're running Debian Linux, make sure this directive reads as follows:

id:2:initdefault

If you're running SUSE, Fedora Core, or Red Hat Enterprise Linux, make sure the id directive reads as follows:

id:5:initdefault

The X Font Server is important to the GUI only on Red Hat/Fedora distributions. If it isn't running, the X Window System won't start. If your system is configured to start in GUI runlevel 5, the screen will just flash for a while. If you try navigating to another console with the Alt-Ctrl-F2 keys, you'll see the console login prompt for a second or two.

After a couple of minutes, you'll see a blue screen with the following message:

I cannot start the X server (your graphical interface). It is likely that it is not set up
correctly. Would you like to view the X server output to diagnose the problem?

If you see the message, you're offered the opportunity to review the logfiles, and then a chance to start the Red Hat display tool. If the X Font Server is not running, the display tool won't start. If you refuse to restart X, Red Hat/Fedora disables the GUI and returns you to the command-line console.

If you can't get back to the command-line console, you'll have to reboot the computer and make sure to restart in a different runlevel. Generally, you can do so at the bootloader with the following steps:

  1. Restart the computer. If necessary, use the power button.

  2. At the bootloader, use the up or down arrow keys to stop the timer.

  3. If a password is required, press p and enter your GRUB bootloader password when prompted.

  4. Press a to display the kernel command line. At the end of the line, enter the runlevel of your choice. For Red Hat/Fedora, this should be runlevel 3, which corresponds to full multiuser mode without the GUI.

Now you can start diagnosing problems with the X Font Server:

As with all annoyances in this book, there is more than one method available to solve problems. In this case, I'll show you how you can keep downloads to a minimum on our selected Linux distributions.

The basic premise is that, as an administrator, you've limited downloads to the /tmp directory. You can further limit user downloads with appropriate quotas as described in "Some User Is Taking Too Much Disk Space" in Chapter 10.

Alternatively, you can extend the scripts shown in this annoyance to the applicable subdirectories for each user.

You can configure the default download directories associated with Internet-related applications such as Firefox. I'll describe the options briefly in Chapter 3. For more information on customizing Firefox for consistent settings, see Firefox Hacks by Nigel McFarlane (O'Reilly).

SUSE Linux manages temporary files through a daily cron job in the /etc/cron.daily directory, known as suse.de-clean-tmp. It's a substantial script that depends on directives set in the /etc/sysconfig/cron configuration file. Generally, you won't need to change anything in the cron job; just modify the /etc/sysconfig/cron as needed. This configuration file includes the directives defined in Table 1-10.

Debian Linux configures the /usr/sbin/tmpreaper command as part of a daily cron job in the /etc/cron.daily directory. It depends on settings that you can configure in /etc/tmpreaper.conf and /etc/default/rcS. I'll examine both the configuration files and the script.

The /etc/default/rcS file is key to a number of configuration files associated with the boot process. The default version of this file includes one related directive:

TMPTIME=0

This specifies the time that files are stored in /tmp in days. The default of 0 specifies that files in /tmp are stored per the TMPREAPER_TIME directive in /etc/tmpreaper.conf.

Now examine the /etc/tmpreaper.conf configuration file, as that is where you can set the directives used in the /etc/cron.daily/tmpreaper cron job. This configuration file includes directives as defined in Table 1-11.

These directives are applied to the tmpreaper cron job in the first few lines of the script. First, this stanza makes sure that the tmpreaper command exists:

if ! [ -x /usr/sbin/tmpreaper ]; then
exit 0
fi

The next stanza checks for and then uses the /etc/tmpreaper.conf configuration file:

if [ -s /etc/tmpreaper.conf ]; then
. /etc/tmpreaper.conf
fi

The script then checks key directives; the default TMPREAPER_TIME is seven days, and the default TMPREAPER_DIRS is /tmp.

TMPREAPER_TIME=${TMPREAPER_TIME:-7d}
TMPREAPER_PROTECT_EXTRA=${TMPREAPER_PROTECT_EXTRA:-''}
TMPREAPER_DIRS=${TMPREAPER_DIRS:-'/tmp/.'}

Finally, the script is run, with a lowered priority (courtesy of nice -n10) to help prevent this job from interfering with other running processes. It avoids deleting directories critical to the running of the Linux GUI.

In this annoyance, I describe the elementary utilities available to our major distributions for configuring sound cards. I then describe the utilities that can help you manage sound events. As this chapter is focused on the desktop, I focus on sound events associated with the GNOME and KDE desktop environments. I also focus on the Advanced Linux Sound Architecture (ALSA), which was incorporated into the current Linux kernel (2.6). If you need detailed information on support for your sound card, refer to ALSA's web site at http://www.alsa-project.org.

When your distribution detects a sound card, it may include commands for the appropriate modules in a file such as /etc/modprobe.conf, /etc/modules.conf, or /etc/modprobe.d/sound.

I've broken this annoyance into distribution-specific sections, followed by the tools associated with the GNOME and KDE desktop environments. You can control the sound environment for all users with the distribution-specific tools. Your users can control their individual sound settings with the GNOME and KDE-based tools.

All three distributions include the alsaconf utility. As you can run it from the console, it's not associated with any particular desktop environment. For more information, see the description of the utility later in this annoyance.

Debian includes the generic ALSA configuration tool, /usr/sbin/alsaconf. While available for the distributions covered in this book, it's the primary tool for Debian—part of the alsa-utils package. Install it, and it can help you configure just about any ALSA-compatible sound card. While you're at the installation process, make sure to download and install the alsa-source, alsa-base, and the libasound2 packages. As the database of ALSA drivers, the alsa-source package is especially important if you have a slightly obscure sound card.

When you start the ALSA configuration tool, take the following steps:

Any special sound-card settings are saved to the /etc/modprobe.d/alsa-base file.

If you want to make sure any changes to sound settings are saved and reapplied the next time you boot Debian Linux, take the following steps:

Now, you can adjust the default sound settings for your system. To do so, run the alsamixer command, which opens a console-based volume tool, as shown in Figure 1-9.

You can navigate among the options with the left and right arrow keys, and change volume levels with the up and down arrow keys. As shown in the figure, you can exit the utility with the Esc key.

Once you make changes, you'll need to run the following command to store the current sound level in /var/lib/alsa/asound.state:

alsactl store