Using and Configuring the GUI and other Configuration Tasks
[Note: Skim this section, it isn’t important for most SAs to know.]
X window is a networking protocol (not a GUI!) that allows X clients to communicate with an X server, and the server with display and input hardware. The X server is running on the local machine (where you are) while the X clients can be run from anywhere. A special X client called the window manager controls the look and feel of windows and icons and cursors.
X clients + - - - X toolkit API (widgets, Motif, TK, GTK, ...)
| - - - - -+ - - - X window protocol
X server- - - - - - -> Window Manager (a special X client)
There are various X servers you can use (or buy), but for Linux the standard for a long time was the open source XFree86. This has been largely replaced by xorg. (see x.org for more info.) The server uses drivers for your video (and input) hardware.
Many WMs available: twm, olwm, mwm, bluecurve, enlightenment, sawfish, compiz, ... Most are configurable. With the right dot files, you can control which WM is used, it’s configuration, which X clients you wish to start automatically, and what fonts and colors to use for various applications. Currently (2010) KDE uses kwin WM and Gnome uses compiz (with add-ons from compiz-fusion) or metacity.
A standard set of menus, applications (such as a panel), icons (e.g., a trash can icon), and services such as support for drag-and-drop, a clipboard, virtual desktops, and GUI development libraries, are considered a desktop environment. Common ones are CDE (Unix), GNOME and KDE (Kool Desktop Environment) for Linux.
Many different WMs are compatible with these. A popular “lightweight” alternative is Xfce. (Some Unixes such as OpenSolaris and Solaris 11 now use Gnome and not CDE.) A system can install several of these and each user can use a different one.
The X server itself must be
configured to know: the type of mouse used, the type of monitor, type of
video card (including how much video RAM:
#pels * bytes/pel <= videoRAM, 8 bits per byte),
location of fonts that X clients can use, which video modes will be supported, and other information. Modern X servers generally probe your hardware and automatically generate a config file (not saved to disk by default). If the file /etc/X11/xorg.conf (old: XF86Config) is there that will be used. It can be edited by hand but usually some tool can be used to generate it.
Xorg provides three ways to configure the X server manually:
1. xorgcfg — A menu based configuration utility that can be run either with a GUI or from the text console (using “-textmode” option).
2. Xorg (or X, the X server) — creates a skeleton configuration file. As root run: Xorg (or X) -configure. The resulting configuration file will be called ~/xorg.conf.new, which will overwrite an existing one if it is there. You edit this file by hand to suit your needs; all available driver options are already listed (mostly commented out), with comments to help you out.
3. xorgconfig — an interactive script which asks you questions about your hardware and creates a configuration file for you. This command doesn’t probe your hardware, you will have to know the values. Google and dmesg are your friends here.
An X client needs to know where to send its output (i.e., where to display it’s windows), the size, location, and other attributes of the windows. Most of this information can be supplied on the X client’s command line using a standard ‑geometry option. (Demo: [kx]calc -geometry [widthxheight]+x+y) (Can use - instead of + to provide X and Y from the right and bottom.)
See man X for details and an overview. See also man pages for: Xserver, X.Org, XConsortium, xhost, xauth, xset, xdm, xorgcfg, xvidtune, xorg.conf, xrandr ‑‑verbose (shows X settings), xdspyinfo (shows server capabilities, extensions, ...), xv, xvinfo, and glxinfo (3D support), xrestop (monitor resources, like top), xrdb (manage .Xresources, which is a legacy text file “registry” to store X app settings), xprop, xwininfo.
The X client can be told which display on which computer to use from the cmd line too (‑display), but most commonly the DISPLAY environment variable is set for this info. The full value is “host:display.monitor” but only the display number is required. (To use the only display on the local system set DISPLAY to ":0".)
To allow remote X clients to popup windows on your desktop, use xhost to grant permission. This basic form of security is so weak that a much better solution is to use SSH to tunnel the X window session, so remote X clients think they are displaying to a local X server.
Demo: ssh ‑X yborstudent /usr/bin/xcalc,xbiff,xeyes,xclock}
To start up the X server: startx.
To switch modes (if more than one configured): CONTROL+ALT+KeypadMinus (or plus). (Demo, showing virtual desktop.)
To stop it type: CONTROL+ALT+BACKSPACE. (If this feature is enabled.)
Unix and Linux usually are configured with several virtual consoles. Usually X runs on console 7 and several text-only (or other X) consoles are enabled. To switch between them use CONTROL+ALT+fn1-7. (F1 console is used as system console, so that’s where console messages will appear.)
To enable a GUI login requires running XDM (or some equivalent GDM or KDM) at boot time. In this case, if you use CTL+ALT+BS to stop X it will automatically restart. XDM is normally started as a service in some run-level or other, but on some BSD (e.g., FreeBSD) systems this may controlled by the /etc/ttys file instead (it depends on the SA’s preference).
To create a larger than the screen size virtual desktop (up to video RAM limit):
Virtual 1280 1024 Horizontal x vertical
Viewport 0 0 Upper left coords of initial screen
echo 'DISPLAYMANAGER="KDE" # which XDM to use
DESKTOP="KDE"#dflt desktop' >/etc/sysconfig/desktop
To enable auto-login (for your physically secure home or office PC), use the KDE GUI tool for that, or for GDM edit /etc/gdm/custom.conf with either:
To configure ALT+Tab to cycle through all open windows, for KDE you right=-click on any window’s titlebar and select “configure window behavior...”. Click on the “Task Switcher” tab, and change the “List Windows” setting to “All Desktops”. For Gnome you need to use ccsm (or maybe saybayon?).
To allow root to login with KDM, change AllowRootLogin=false to true in the kdmrc file (location depens on your system). There is a similar file for GDM (/etc/gdm/custom.conf on Fedora). PAM is also used to control this for some XDMs (e.g., modern Gnome). You need to comment out the following line (if it exists) in the files /etc/pam.d/[kgx]dm*:
auth required pam_succeed_if.so user != root quiet
You will also need to set root’s password on Ubuntu; accounts with no password set are locked.
Demo and discuss:
· Customizing KDE (virtual desktops) and Gnome (/etc/xdg/*, ~/.config, *.desktop), Sabayon for Gnome.
· Sticky icons & windows (“keep on all desktops”), moving windows between desktops
· using the mouse for copy (left button) and paste (middle button)
· iconizing, docking (application icon on the system tray part of the panel)
· adjusting the panel and menus
· Using KEdit, xterm, xmessage. (or osd_cat, part of xosd pkg)
· Managing removable media (mtools, mount, auto-mount, icons, PAM)
· Demo Add an icon. (sabayon)
Xvfb is an X server that can run on machines with no display hardware and no physical input devices. It emulates a dumb framebuffer using virtual memory. The main use of this was intended to be application testing without the need for real hardware that supports desired features. Other uses for Xvfb include testing clients against unusual depths and screen configurations, doing batch processing with Xvfb as a background rendering engine, load testing, and providing an unobtrusive way to run applications that don’t really need an X server but insist on having one anyway. See also xwd and xwud for screen shots.
Example: To install Perl’s Tk.pm module without running X, boot
to run-level 3 and login as root. Then:
# Xvfb :0 & cpan Tk; \
kill `pidof Xvfb`
Understanding and Managing Fonts
Unix systems have traditionally weak support for fonts. After all, most servers lack any sort of GUI! One thing you can do is to change the font used for the system console (or virtual consoles) on Linux using the setfont command. The default font to use is configured someplace; on Fedora look for SYSFONT in /etc/sysconfig/i18n. For other systems (BSD, Debian) grep rc.conf for “font”. Console fonts are in a special format, and the ones on your system are installed one place or another; try find / ‑type d ‑name \*font\*. On Fedora they’re in /lib/kbd/consolefonts. (The font files used should be in the root partition, or they can’t be used after mounting.)
What You Should Know About Computer Fonts
[Adapted from: “A Font Primer for Linux”, by Nathan Willis, posted at www.linux.com/archive/feature/39513 on 10/12/04.]
The earliest digital fonts were nothing but dots: monochrome bitmaps. Every character was handmade for each available point size. That ensured they would be clear and legible at those point sizes, but forcing interpolation if you wanted a size that the font foundry (a foundry is a company that produces fonts) did not supply. This leaves jagged edges when increasing letters in size and indistinct blobs when decreasing. One solution was to supply each font in many sizes. This includes font variations such as bold or italics; each is a different “font”.
Another approach is possible though: have fonts that defined their characters with smooth curves. These are called “outline” fonts. Such fonts can be drawn at any size. (Consider a slash “/”: the font can say the slash is y=4x, and you just compute each <x,y> point to draw the slash, for as many points as desired.) Such outline font files are fairly small (much smaller than a whole set of font files for a bit-mapped font at many sizes). Also outline fonts can be manipulated to produce variations such as bold or slanted.
By the late 1980s the two major desktop system vendors, Apple and Microsoft, as well as software maker and foundry Adobe (who led the desktop publishing revolution) all agreed to use outline fonts. Adobe was pushing its PostScript technology for printers and tried to get the systems vendors to license the new, scalable “Type 1” font technology it had designed to go with it. But Apple and Microsoft were wary of the idea, because although PostScript was an open standard, “Type 1” was closed and proprietary.
Apple and Microsoft made a deal: Apple would produce an open font for PostScript, MS would include a PostScript interpreter with Windows, and they would share.
As usual MS produced a proprietary, incompatible PostScript system called “TrueImage”. Nobody every used it since Adobe PostScript was freely available anyway. But the Apple font technology caught on and evolved into “TrueType” fonts. Besides TrueType and PS Type 1 fonts, Adobe has released other outline font types (e.g., “Type 3”) but they are not as popular.
The conflicting font types were an annoyance since you had to have (and pay the licenses for) multiple font rendering libraries on your system. Fortunately in 1996 Adobe introduced OpenType, a new format that can encapsulate both Type 1 and TrueType fonts, and introduces some newer features as well. The current versions of Windows, Mac OS X, and Linux include support for OpenType.
The X window system originally only supported bit-mapped fonts. The console drivers still only use bit-mapped fonts. Today X window does use outline fonts, but still ships with some of the older bit-mapped fonts to support legacy applications. These are packaged in a special format.
Table showing the file extensions for some common font types
PostScript Type1 (ASCII)
Adobe and various foundries
PostScript Type1 (binary)
Adobe and various foundries
PostScript Type 3
Adobe and various foundries
Portable Compiled Format (bitmapped)
Bitmap Distribution Format
Modern X Servers: FreeType
XFree86 v4 introduced a new extension to the X protocol called Xft to enable the use of scalable fonts. Xft uses the FreeType library, an open source scalable font renderer that supports Type 1, TrueType, and OpenType fonts, in addition to a number of less common formats. FreeType is modular and extensible in design with a separate “font driver” for each font type. FreeType is now used for all *nix systems today (I think).
FreeType has one problem with outline fonts. Apple holds patents on the “hinting” system that tweaks the TrueType fonts to make the look better at various sizes. (As Adobe does for Type 1 fonts.) So the FreeType system ignores any hinting information supplied with the fonts and attempts to tweak the fonts with its own hinting. This rarely looks as good but it is the best that can be done.
Fontconfig (see www.freedesktop.org/wiki/Software/fontconfig) is a library to simplify finding and accessing the fonts on a given system. Fontconfig can auto-discover the fonts installed on your computer, automatically find the correct font for a given language or character set, and let you configure your own personal font preferences (including substitutions) with XML configuration files.
Besides a number of GUI front-ends, fontconfig includes some command line tools to manage and view font information: fc-cache, fc-list, and fc-match.
Fontconfig has system-wide configuration files in /etc/fonts, which says (among other things) where the font files are on the system, which fonts contain which Unicode glyphs, and other information.
There is also a per-user configuration file ~/.font.conf. You can edit that file to make the system substitute one font for another. The default configuration will auto-discover any outline font files placed in the directory ~/.fonts. This font.conf file will block the font Arial and replace it with Liberation Sans:
<!DOCTYPE fontconfig SYSTEM "fonts.dtd">
You can paste in additional sections of the file to mandate other font swaps, and this trick works just as well on Linux as on OpenSolaris.
www.x.org/X11R6.8.2/doc/fonts.html shows how to add fonts for some other Unix systems.
Managing Fonts on Legacy Unix and Linux Systems
There was (is) an older and a newer X font system as part of the X server. Some apps used the very old one, more modern (but still considered legacy today) apps use the newer one. Sadly there are lots of such system still in use and you may need to manage one someday.
The old X font system only could handle bit-mapped fonts in special X formatted font files. All X fonts had logical font names, very long names that contained 14 fields listing all the font properties in the format, in a pre-defined location:
The idea of these is that you could find a font with specific properties by using ls and wildcards: ls -*-*-bold-*-*-*-12-*-*-*-*-*-*-*
In addition to those fonts, the newer X system can find font files directly if they are listed on the server’s font path. The newer system uses the config files in the /etc/X11/fontpath.d directory to locate fonts.
Modern bit-mapped fonts have much shorter file names (and you can define your own aliases for font names). However it is time-consuming to determine the font properties that the logical name provides. So that data must be computed in advanced and cached in files (and RAM).
With the modern (but still legacy) system, each directory containing fonts must contain the file fonts.dir which maps the file names to the X logical font names and provides a handy index of the fonts in the directory for X to use. These bitmapped fonts use a short name with the “.pcf” extension. Use mkfontdir to generate the fonts.dir files. Use xset fp+ directory to update the X server’s font path, and xset fp rehash to rebuild the X server’s font cache.
Using the X Font Server (Legacy X Servers Only)
These older X servers only understand bitmapped fonts. But some come with an X font Server (or “XFS”). The X server is configured to use bit-mapped fonts, XFS, or a combination. Besides the modern bit-mapped X fonts (the short filenames with “.pcf” extension) XFS can use TrueType fonts (with the extension “.ttf”) or PostScript fonts (with the extensions “.pfa” or “.pfb”, plus an additional font metrics file “.afm”). Some other font types may be supported as well.
The X font server has a different set of utilities: to manage font files, to generate font directory index files, and to update the XFS font cache. Use chkfontpath to configure font directories. (For systems lacking this command you need to edit the font server’s config file.)
You build an index of fonts for each font directory. If the directory contains Type1 fonts run mkfontscale which creates the index file fonts.scale. If the directory contains any TrueType fonts run ttmkfdir which creates the same file.
Because these commands overwrite any previous fonts.scale file you can’t put TrueType and Type1 fonts in the same directory. However it is safe to include bit-mapped fonts in these directories.
The fonts.scale file and any bit-mapped fonts in the directory are used to create the fonts.dir font index file by running mkfontdir command on it.
Finally you must kick the font server (or X) to make it refresh its cached list of available fonts, by re-examining all the indexes in all the directories listed on the font path. This is done by sending SIGHUP signal (via kill) to the X font server (or X).
Run xset q to see which directories are listed on X’s fontpath, chkfontpath to see the xfs fontpath. To see which fonts are available use xlsfonts. The X font server uses fslsfonts to show just the fonts known to the font server (/etc/X11/[x]fs/config). To see the characters in a given font use the xfd command.
Remote desktop control software
VNC (Virtual Network Computing) software makes it possible to view and fully-interact with one computer from any other computer or mobile device anywhere on the Internet. VNC software is cross-platform, allowing remote control between different types of computer. There is even a Java viewer, so that any desktop can be controlled remotely from within a browser without having to install software. (http://www.realvnc.com/) There are different vendors of VNC (TigerVNC, RealVNC, TightVNC, ...) and they don’t all work the same. Some alternatives such as rdesktop will also work with Windows Terminal services (now called Remote Desktop Connection or RDC). Also PC Anywhere, DS View. See Wikipedia “Remote Desktop Software” for comparisons.
Adding to Gnome’s context menu
Here’s also a way to automate the process where you mount your USB flash drive without having to type anything at a command line. (If you have a modern 2.6 Linux kernel and udev and hotplug support, this shouldn’t be needed at all.)
In Gnome, when you right-click anywhere on the desktop one of the menu choices you have is Scripts, which is a quick and easy way to execute shell scripts without having to open a terminal window.
All you need to do is add a script to the right folder. By default there are no scripts in the folder that the Scripts menu points to but there is an option to open that folder. Once in the folder create a new text file and open it in your favorite text editor to write the following script:
We run the modprobe command just to make sure that the usb-storage module is loaded. If it’s already loaded, there’s no harm done, and if it wasn’t already loaded, now it is. [ I bet all that is needed is the mount cmd once the appropriate mount point exists and fstab entry is created. ]
Save the script as something like “mount usbstick” and copy it into the ~/.gnome2/nautilus-scripts directory.
Set the script as executable by the appropriate groups/users.
Now when you right-click on the desktop and go down to the Scripts menu choice, in the Scripts sub-menu you should see your mount usbstick script.
If you have your USB flash drive mounted as a volume, you can right-click on it and the bottom menu choice should be Unmount Volume. Use this to unmount the volume before physically removing the USB flash drive.
The next time you insert the flash drive into an available USB port, right-click on the desktop, go into the Scripts sub-menu, and execute your mount usbstick script. The drive icon for your flash drive should appear on your desktop.
On a Unix system you will need to configure CDE. For some reason CDE commands are prefixed with “dt”, as in dtterm for xterm, dtwn (the CDE standard window manager), and dtfile for a GUI file manager. The CDE equivalent of XDM is dtlogin. Dtlogin works in a client-server mode; dtlogin waits for an X device to connect by way of an XDMCP request, and then communicates with your local X server by setting DISPLAY on the server machine (i.e., the X programs all run on the remote server but send their GUI to your local X server) and running dtgreet (login).
The shipped default configuration is in /usr/dt, you shouldn’t edit this as updates will over-write it. The system-wide defaults are in /etc/dt, and a user can over-ride that with ~/.dt. All three locations share a common directory structure.
Tired of not having NumLock on by default? For Linux try: yum install numlockx (from: ktown.kde.org/~seli/numlockx/). For the non-GUI consoles a standard program “setleds” can be used to turn NumLock on or off. You can use setleds in some boot up script, say /etc/rc.d/rc.local, to turn on NumLock by:
for tty in $INITTY; do
setleds -D +num < $tty
Configuring X Applications
GConf is a system used by GNOME (and sometimes KDE too) for storing configuration settings (a.k.a. user preferences) for the desktop and applications. This configuration data is not stored in standard dot-files but in a database of XML files under ~/.gconf. (A kind of registry...yuck!) The (per user) daemon GConfd watches out for changes to these files and applies the new settings to (GConf-aware) applications immediately. The GUI config tools that use GConf require users to press an “OK” or “Apply” button to make changes come into effect.
Many X programs (especially older ones that don’t ship with KDE, Gnome, or CDE) can be configured with default window locations and sizes, colors, font choices, and more by adding entries to your ~/.Xresources file. Each line in this file has the form: programName*resourceName: value. Here’s a sample:
This file’s settings are merged with the system-wide Xresources file using the xrdb command in the X startup script (or XM=DM’s session startup script). See man page for X(7) for details.
The keys on your keyboard can be mapped to various (Unicode) characters by creating ~/.Xmodmap, read with the xmodmap command. This can be useful for assigning values to special keys on a keyboard. Keys are also mapped with loadkeys(1) for non-GUI (tty driver) consoles.
To adjust Firefox (Iceweasel) so that it launches Thunderbird instead of evolution, xfce 4.x has default application chooser use that. The other way is using firefox’s own app chooser: about:config, then Network.protocol-handler.app.protocol. For some RH-based distros Gnome is in charge of this setting instead. The way to fix it is to launch gnome-control-center, and choose “Preferred Applications”, and adjust as needed.
You can adjust these manually too. In $HOME/.thunderbird/*/prefs.js put the lines:
In $HOME/.mozilla/firefox/*/prefs.js put the line:
(or, more comfortably, edit it in Firefox with “about:config”.) Of course “firefox” and “thunderbird” need to be in your PATH.
FYI: Popular CD ripping tools: grip, abcde, cdparanoia.
Installing Nvidia Drivers on a Fedora System
First make sure you have added both rpmfusion repositories to yum. Then for GeForce 6, 7, 8, 9 & 200 series cards:
yum install kmod-nvidia xorg-x11-drv-nvidia-libs.i686
or if using a PAE kernel: yum install kmod-nvidia-PAE
For the older GeForce FX cards: yum install \
or if using a PAE kernel: yum install kmod-nvidia-173xx-PAE
Next you need to edit either grub.conf or /etc/modprobe.d/blacklist.conf to ensure the default neoveau driver won’t be used. You will need to rebuilt the initial ram disk after this change. To edit grub.conf:
-i '/root=/s|$| rdblacklist=nouveau|' \
To edit /etc/modprobe.d/blacklist.conf:
Then regenerate the inital ram disk:
/boot/initramfs-$(uname -r).img \
dracut /boot/initramfs-$(uname -r).img $(uname -r)
Lastly, due to the way the Nvidia drivers are written you need to enable allow_execstack so SElinux doesn’t prevent the driver loading:
setsebool -P allow_execstack on
You may also need to update xorg.conf (especially with compiz), and use the commands glxinfo, rhpxl, system-config-dispaly, and nvidia-settings. For details, see: forums.fedoraforum.org/showthread.php?t=204752