Filewatcher File Search
FTP Search
  
Directory 
  
Content Search 
   
pkg://linux-howtos-20070609-1.pkg.tar.gz:8932270/usr/share/linux-howtos/XWindow-User-HOWTO  downloads

The X Window User HOWTO

Hal Burgiss

     hal@foobox.net
    

v3.1 10 October 2002
Revision History                                                             
Revision v3.1            2002-10-10            Revised by: hb                
Some minor additions and updates.                                            
Revision v3.0            2002-03-06            Revised by: hb                
Rewrite of the original document. Convert to DocBook. Many, many changes.    


This document provides basic information on understanding and configuring the
X Window System for Linux users. This is meant to be an introductory level
document. A basic knowledge of software configuration is assumed, as is the
presence of an installed and working X Window System. 

-----------------------------------------------------------------------------
Table of Contents
1. Introduction
    1.1. New Versions and ChangeLog
    1.2. To Do
    1.3. Feedback
    1.4. Help!
    1.5. Acknowledgments
    1.6. Copyright
    1.7. Standard Disclaimer
   
   
2. XFree86
    2.1. Hardware
    2.2. XF86Config
    2.3. xvidtune and Monitor Tuning
   
   
3. Running X
    3.1. startx
    3.2. Display Managers
   
   
4. More X Configuration
    4.1. X Resources
    4.2. xmodmap, the Keyboard and Mice
    4.3. xset
   
   
5. Fonts and Colors
    5.1. Fonts Demystified
    5.2. Colors
   
   
6. Window Managers and Desktops
    6.1. Window Managers
    6.2. Desktop Environments
   
   
7. X and the Command Line
    7.1. xterm and friends
   
   
8. X Networking and Security
9. Performance Considerations
    9.1. Hardware
    9.2. Memory
    9.3. X over the Network
    9.4. Other Tips
   
   
10. Appendix
    10.1. Terminology and Usage
    10.2. Links and other References
   
   

1. Introduction

The X Window System is an advanced, graphical computing and network
environment that was designed from the ground up as a multi-user system. X
was first released in 1984. If you are not familiar with the basic concepts
surrounding X and it's related components, you should first read the X Window
System Architecture Overview HOWTO, [http://linuxdoc.org/HOWTO/
XWindow-Overview-HOWTO/index.html] http://linuxdoc.org/HOWTO/
XWindow-Overview-HOWTO/index.html, to get an idea of how the various pieces
fit together. There is also an attempt to define to various X related
terminology in the Appendix, if concepts such as "displays" and "X clients"
in this context are confusing to you. 

This document will address basic X Window configuration and usage on Linux.
We will also look at how X is commonly started in Linux, and how the start up
can be configured, and related issues. We will not examine Window Manager
(e.g. fvwm), or Desktop Environment (KDE and GNOME) configuration. There are
just too many variables there, and the pace of change moves too quickly. Of
course, to a large extent the user interacts more directly with these
components than the X server itself, so additional reading would be
worthwhile. Check your locally installed documentation, and the respective
home pages for more information. 

Some other important points to remember here: 

  * X is a client-server, multi-user system in every respect, and not just a
    GUI.
   
  * X is not integrated into the operating system, and rides on top of it,
    like other servers.
   
  * X is an open standard, and runs on many platforms.
   
  * What you actually see on the screen is the result of various components,
    all working together: operating system, X, Window Manager, and
    optionally, a desktop environment like GNOME or KDE. These are all "plug
    and play" components, meaning you can interchange an individual component
    without touching the other components.
   
  * Each of the various components has its own configuration. This makes for
    a very flexible, and potentially very robust, system. It also adds
    complexity.
   

The discussion here will be limited to X as implemented by The XFree86
Project, Inc. on Linux. There are other implementations, including commercial
ones. XFree86 v4.x has been out for some time now, so we will be assuming
that version. Much of the discussion applies to the previous 3.x version as
well, but there are some occasional differences. 

It is also worth noting that there are conceivably many ways to start X, and
to set up a Linux system. We will focus on the common methods found in Linux
distributions. Also, vendors may vary on where they put configuration files,
and how they name them. Keep this in mind if you see such discrepancies in
this document. If this is a problem, your vendor surely has their own
documentation. And as always, hopefully the man pages will conform to your
installation. 

Also, we will look at various configuration files in the following sections.
These are all plain text files, and can be edited with your favorite editor.
Always make a backup copy before editing important files, in case Murphy pays
a visit (e.g. "cp /etc/X11/XF86Config-4 /etc/X11/XF86Config-4.bak"). 
-----------------------------------------------------------------------------

1.1. New Versions and ChangeLog

The current official version of this HOWTO may be found at the Linux
Documentation Project, [http://www.linuxdoc.org/HOWTO/
XWindow-User-HOWTO.html] http://www.linuxdoc.org/HOWTO/
XWindow-User-HOWTO.html. Pre-release versions may be periodically posted to
[http://feenix.burgiss.net/ldp/x-user/] http://feenix.burgiss.net/ldp/x-user
/.

v3.1: This is just some small, minor updates. Include link to [http://
www.plig.org/xwinman/] http://www.plig.org/xwinman/ as a good resource for
shopping Window Managers. Add link for fluxbox, a Window Manager with Tabbed
windows. And add a brief section on improving network performance. Verify
links all work.

v3.0: This is a major rewrite with several new sections. Some sections were
removed, with the focus more now on just X itself (and not clients like
Window Managers). New maintainer too :-)

v2.0: includes corrections from Guus Bosch, Brian J. Miller, and myself, as
well as lots of new updates and info.

v1.4: include corrections and additions from Anthony J., and some very good
security tips from Tomasz Motylewski.
-----------------------------------------------------------------------------

1.2. To Do

A rudimentary troubleshooting section. Probably for v3.2. 
-----------------------------------------------------------------------------

1.3. Feedback

If you have questions or comments about this document, please feel free to
email me, Hal Burgiss at <hal@foobox.net>. I welcome any suggestions,
corrections, or additions. If you have information you would like to see in
future revisions, or you would like to contribute to a future revision,
please drop me a note.  
-----------------------------------------------------------------------------

1.4. Help!

I have assumed maintainership of this document because it was abandoned, and
I had wanted to offer a suggested change. Well, to make a long story short,
this led to a major re-write. You can help make this a better document by
correcting inaccuracies, clarifying the unclear, and suggesting improvements.
There is much about this topic I may not know, or not have explained well.
Your help will improve this document and help other users. This document 
needs your help!
-----------------------------------------------------------------------------

1.5. Acknowledgments

Thanks to the XFree86 development team for their efforts in providing a
robust and flexible GUI. And to the whole GNU/Linux and Open Source community
for making it all possible.

Also, the original author, Ray Brigleb. 

Various users on comp.os.linux.x that have helped in one way or another,
whether they know it or not. 

Lastly, [http://google.com/linux] http://google.com/linux, who saved me much
time with their incredible repository of information. Use it to answer
questions not answered here! 
-----------------------------------------------------------------------------

1.6. Copyright

Copyright © 2002, Hal Burgiss.

Unless otherwise stated, Linux HOWTO documents are copyrighted by their
respective authors. Linux HOWTO documents may be reproduced and distributed
in whole or in part, in any medium physical or electronic, as long as this
copyright notice is retained on all copies. Commercial redistribution is
allowed and encouraged; however, the author would like to be notified of any
such distributions.

All translations, derivative works, or aggregate works incorporating any
Linux HOWTO documents must be covered under this copyright notice. That is,
you may not produce a derivative work from a HOWTO and impose additional
restrictions on its distribution. Exceptions to these rules may be granted
under certain conditions; please contact the Linux HOWTO coordinator for more
information.

In short, we wish to promote dissemination of this information through as
many channels as possible. However, we do wish to retain copyright on the
HOWTO documents, and would very much like to be notified of any plans to
redistribute the HOWTOs, this one in particular!

Some of the terms mentioned in this document are trade names. Unless
otherwise stated, all trademarks are property of their respective owners.

"X Window System" is a trademark of the X Consortium, Inc [now the
OpenGroup?]. 

"XFree86" is a trademark of The XFree86 Project, Inc. 

"Linux" is a Registered Trademark of Linus Torvalds.
-----------------------------------------------------------------------------

1.7. Standard Disclaimer

The information and examples given here are for illustrative purposes. Use at
your own risk. Every attempt has been made to insure that the content of this
document was accurate when written. If you find inaccuracies, please send me
clarifications. 

References to any particular company, product or brand name should not be
construed as an endorsement. 
-----------------------------------------------------------------------------

2. XFree86

Virtually every Linux distribution comes with XFree86's X Window System
implementation. This project, of course, provides us the X server, but also
includes an extensive suite of utilities and applications to help implement a
fully functional GUI environment. 

In fact, the list would be just too long to list everything that comes with
XFree86. In addition to the X server itself, here are a few of the noteworthy
utilities:

xdm - the X Display Manager.

xfs - the X Font Server.

twm - a lightweight Window Manager.

xterm - the best known terminal emulator. Also, xterm3d and nxterm.

xwd - a screen and window image capturer.

xf86config - X server configuration utility.

xdpyinfo - X display information utility. This shows great detail about the X
server.                                                                      

xlsclients - lists currently connected X server clients.

xlsfonts - lists fonts available to X.

appres - lists the X "resources" that a program will use.

xfontsel - an application for viewing or selecting fonts.

xprop - a tool for displaying window "properties", such as the Class name of 
the client.                                                                  

xset - sets user preferences for many things, including mouse, keyboard,     
sound (bell), etc.                                                           

xsetroot - a program for changing the "root window" appearance, e.g. setting 
a background color.                                                          

xvidtune - an application to adjust X server video modes and monitor related 
settings.                                                                    

xwininfo - displays information about a selected "window".

xmodmap - a utility for manipulating keyboard and mouse button mappings.

Many, many fonts. And quite a bit of documentation as well.

There are many more. We'll just touch on a few of these utilities here. But
feel free to explore the others. Most should have their own man pages. 
-----------------------------------------------------------------------------

2.1. Hardware

The X server controls both input (keyboard, mouse, etc) and output (display,
monitor) devices. 

Compatible hardware is a tough topic, since it is very much a moving target.
We are forced here to avoid specifics, since this would surely change by the
time you read this. And would be tediously lengthy anyway. 

So let's settle for some generalities. Most PC type hardware is supported to
one degree or another. Big help ;-) 

Rule of thumb: if it is a device that uses a long-standing, commonplace
protocol (e.g. PS/2), it should be well supported. Conversely, if it is
something relatively new, with ground-breaking technology, the odds are not
as good. This is just the nature of the beast with open source development
versus manufacturers that cater more to the most popular platforms. Some
manufacturers are more co-operative than others too. 

Now, some general guidelines: 

  * Monitors - This is easy. Linux does not really need to be compatible with
    the monitor per se. That is the job of the video card. Any monitor that
    your graphics card can drive should do fine. Including, flat panel
    monitors.
   
  * Video cards - This is much tougher. The X server is determined by the the
    chipset. Many, many are supported. But inevitably there are always some
    newer cards, or even revised cards, that are not. And some may have
    better support and better optimization than others. Advanced features
    such as multi-headed displays, 3D, TV out, DRI, etc., have some support
    as well, though this should be researched first, as the support may be
    limited. Supported cards are listed: [http://xfree86.org/cardlist.html]
    http://xfree86.org/cardlist.html.
   
    Open source drivers are often developed incrementally. For instance, a
    particular card may work well for basic display purposes, but specialized
    features such as 3D may come much later in the development cycle. This is
    a quite different development model than with proprietary drivers from
    the manufacturer.
   
  * Keyboards -- Any standard PC type keyboard should do fine, including PS/
    2, USB and many infra-red devices. Probably many "non-standard" ones too
    ;-)
   
  * Mice and other pointer devices -- Most should be supported including PS/
    2, bus, serial, USB and many infra-red devices. Optical mice also. Unix
    has long preferred three button mice, though more buttons is supported as
    well. Many wheeled mice have X server support via the "IMPS/2"
    (IntelliMouse), or other specific protocols, though may require
    supplemental configuration for some individual applications. (See the 
    Links section.)
   
  * Laptops have their own unique set of problems since the hardware tends to
    be very specialized, and often different from what is commonly found on
    desktop style systems. X is supported by many. Check for details at
    [http://www.linux-laptop.net/] http://www.linux-laptop.net/.
   

You can check the "hardware compatibility list" at your distribution's web
site too. This should give a very good idea of what should work with your
release. 

Newer versions of XFree86 obviously will have better hardware support. If you
are using an older Linux version and don't have full hardware support, see
about upgrading XFree86. Check first to see if your distribution has updates
for your release. 
-----------------------------------------------------------------------------

2.2. XF86Config

The primary configuration file for XFree86 is XF86Config, which may exist on
your system as XF86Config-4 for XFree86 v4.x, or possibly other variations
(see man page). It is typically located as /etc/X11/XF86Config, though again,
there may be variations in the path. If both a XF86Config-4 and XF86Config
exist, XFree86 v4.x will use the former. This is a required file. 

XF86Config file defines hardware devices, and other critical components of
the X server environment.  

While this is a plain text file, and is editable, it is most often created
during installation by whatever utility your vendor uses for this purpose.
XFree86 also includes the xf86config utility for this, but many distributions
have their own such utilities. These utilities can be run after installation
if need be, to alter the configuration, or if new hardware is installed. Read
your locally installed documentation first. If you attempt to hand edit this
file, be sure to make a backup copy first since X won't start if this file is
not to its liking ;-) 

This file contains various "sections". Each section defines some fundamental
aspect of XFree86, such as "InputDevice" (mouse, keyboard, joystick, etc), 
"monitor", or "screen". The XF86Config man page describes the sections and
common values for each. Note that the values listed in the man page is not a
comprehensive listing. There are many device specific "options". Check [http:
//xfree86.org] http://xfree86.org for notes and tips on your hardware. 

The author's current XF86Config-4, as generated by Red Hat's installer for
XFree86 4.1: 

+------------------------------------------------------------------------------------------+
|Section "ServerLayout"                                                                    |
|        Identifier "XFree86 Configured"                                                   |
|        Screen      0  "Screen0" 0 0                                                      |
|        InputDevice    "Mouse0" "CorePointer"                                             |
|        InputDevice    "Keyboard0" "CoreKeyboard"                                         |
|EndSection                                                                                |
|                                                                                          |
|Section "Files"                                                                           |
|   # The location of the RGB database.                                                    |
|   RgbPath     "/usr/X11R6/lib/X11/rgb"                                                   |
|                                                                                          |
|   # Multiple FontPath entries are allowed (they are concatenated together)               |
|   # By default, Red Hat 6.0 and later now use a font server independent of               |
|   # the X server to render fonts.                                                        |
|   FontPath "unix/:7100"                                                                  |
|EndSection                                                                                |
|                                                                                          |
|# Module loading section                                                                  |
|                                                                                          |
|Section "Module"                                                                          |
|        Load  "dbe"             # Double-buffering                                        |
|        Load  "GLcore"          # OpenGL support                                          |
|        Load  "dri"             # Direct rendering infrastructure                         |
|        Load  "glx"             # OpenGL X protocol interface                             |
|        Load  "extmod"          # Misc. required extensions                               |
|        Load  "v4l"             # Video4Linux                                             |
|#    Load  "fbdevhw"                                                                      |
|     Load  "pex5"                                                                         |
|     Load  "record"                                                                       |
|     Load  "xie"                                                                          |
|EndSection                                                                                |
|                                                                                          |
|                                                                                          |
|Section "InputDevice"                                                                     |
|        Identifier  "Keyboard0"                                                           |
|        Driver      "keyboard"                                                            |
|        Option      "XkbLayout" "us"                                                      |
|                                                                                          |
|#    Option  "AutoRepeat"    "500 5"                                                      |
|                                                                                          |
|# when using XQUEUE, comment out the above line, and uncomment the                        |
|# following line                                                                          |
|#    Option  "Protocol"      "Xqueue"                                                     |
|                                                                                          |
|# Specify which keyboard LEDs can be user-controlled (eg, with xset(1))                   |
|#    Option  "Xleds"         "1 2 3"                                                      |
|                                                                                          |
|# To disable the XKEYBOARD extension, uncomment XkbDisable.                               |
|#    Option  "XkbDisable"                                                                 |
|                                                                                          |
|# To customize the XKB settings to suit your keyboard, modify the                         |
|# lines below (which are the defaults).  For example, for a non-U.S.                      |
|# keyboard, you will probably want to use:                                                |
|#   Option  "XkbModel"      "pc102"                                                       |
|# If you have a US Microsoft Natural keyboard, you can use:                               |
|#   Option  "XkbModel"      "microsoft"                                                   |
|EndSection                                                                                |
|                                                                                          |
|Section "InputDevice"                                                                     |
|        Identifier  "Mouse0"                                                              |
|        Driver      "mouse"                                                               |
|        Option      "Device" "/dev/mouse"                                                 |
|        Option      "Protocol" "IMPS/2"                                                   |
|        Option      "Emulate3Buttons" "off"                                               |
|        Option      "ZAxisMapping" "4 5"                                                  |
|EndSection                                                                                |
|                                                                                          |
|Section "Monitor"                                                                         |
|        Identifier "Sylvania F74"                                                         |
|        VendorName "Unknown"                                                              |
|        ModelName  "Unknown"                                                              |
|        HorizSync   30 - 70                                                               |
|        VertRefresh 55 - 120                                                              |
|        Option "dpms"                                                                     |
|#    Modelines go here if necessary. Use xvidtune to get proper values.                   |
|EndSection                                                                                |
|                                                                                          |
|Section "Device"                                                                          |
|        Identifier "ATI Rage 128"                                                         |
|        Driver "r128"                                                                     |
|        BoardName "Unknown"                                                               |
|EndSection                                                                                |
|                                                                                          |
|Section "Device"                                                                          |
|        Identifier "Linux Frame Buffer"                                                   |
|        Driver "fbdev"                                                                    |
|        BoardName "Unknown"                                                               |
|EndSection                                                                                |
|                                                                                          |
|Section "Screen"                                                                          |
|        Identifier "Screen0"                                                              |
|        Device "ATI Rage 128"                                                             |
|        Monitor "Sylvania F74"                                                            |
|        DefaultDepth 24                                                                   |
|        Subsection "Display"                                                              |
|                Depth 24                                                                  |
|                Modes "1400x1050" "1280x1024" "1152x864" "1024x768" "800x600"             |
|        EndSubSection                                                                     |
|        Subsection "Display"                                                              |
|                Depth 16                                                                  |
|                Modes "1600x1200" "1400x1050" "1280x1024" "1152x864" "1024x768" "800x600" |
|        EndSubSection                                                                     |
|        Subsection "Display"                                                              |
|                Depth 8                                                                   |
|                Modes "1024x768" "800x600" "640x480"                                      |
|        EndSubSection                                                                     |
|EndSection                                                                                |
|                                                                                          |
|Section "DRI"                                                                             |
|        Mode 0666                                                                         |
|EndSection                                                                                |
|                                                                                          |
|                                                                                          |
+------------------------------------------------------------------------------------------+

Yours may look quite different. This is just one possible configuration with
gratuitous comments from Red Hat (and me), and is for a fairly ordinary set
up. There is nothing exotic here like multiple screens or displays. 

It is beyond the scope of this document to explain this in detail. See the
XF86Config man page. Also, consider visiting [http://xfree86.org] xfree86.org
and look for specific options that might apply to your card or other
hardware. 

Just one quick note on the "Screen" section above. Notice there are three
sub-sections, identified as "Display". Each sub-section has a different 
"Depth" specified, (a.k.a. ColorDepth). The "Modes" also vary somewhat
according to the respective "Depth" setting. The active "Display" sub-section
that will be used, is determined by the "DefaultDepth" setting (unless
over-ridden by command line options). The default in this example is defined
as "24", so the first sub-section will be used. Also, the highest "Mode"
listed in this sub-section will be the default mode (resolution), which here
is the first one listed. The first listed mode also determines the viewable
screen area, which can be smaller than the mode (resolution) itself. In which
case, you would have a virtual desktop that is larger than the viewable
screen. To have the viewable screen, and resolution match, have the largest
value as the first value listed for each "Mode". 

Another note on the "Modes" here: what you see is the result of my choices
during Red Hat's Xconfigurator's configuration. These are standard
resolutions, but do not have to be! This is only limited by what your
hardware can support. And you don't have to use standard width x height
ratios either. Something like 1355x1112 is a valid setting (if your hardware
supports it and it floats your boat!). 

The X server will reject any "Modes" it thinks are invalid. You can cycle
through valid modes to change screen resolution with Ctrl-Alt-+ and
Ctrl-Alt-- (that's the keypad plus and minus keys). 

In versions prior to v4.x, you would also see many "Modeline" statements that
attempted to define the monitor's capabilities. These statements would look
something like: 

+-----------------------------------------------------------------------------------+
| # 1024x768 @ 100Hz, 80.21 kHz hsync                                               |
| Modeline "1024x768"  115.5  1024 1056 1248 1440  768  771  781  802 -HSync -VSync |
|                                                                                   |
|                                                                                   |
+-----------------------------------------------------------------------------------+

Explicit "Modeline" definitions are not required as of 4.x ;-) This sometimes
required hand editing to get optimal values in earlier versions of XFree86,
though is generally not necessary with v4.x. The XFree86 Video Timings HOWTO,
[http://www.linuxdoc.org/HOWTO/XFree86-Video-Timings-HOWTO/index.html] http:/
/www.linuxdoc.org/HOWTO/XFree86-Video-Timings-HOWTO/index.html has a nice,
but rather technical, explanation of this. 

If whatever configuration utility you are using, does not automatically
recognize your video card or monitor specifications correctly, you are
unlikely to get an optimal configuration. In such cases, you may have to
manually supply the correct values. This should be available from your
owner's manual (you kept that, right?). Or, check the manufacturer's web
site. 

Again, hand editing of this file is generally unnecessary. Should you decide
this is indeed necessary, be careful. One small error may cause X to fail.
Any changes to this file will require restarting X for the changes to take
effect. 

Using somebody else's XF86Config file, is generally a bad idea since they are
unlikely to have identical hardware. 
-----------------------------------------------------------------------------

2.3. xvidtune and Monitor Tuning

You probably want to get the most out of your hardware. If X isn't configured
optimally, consider re-running your vendor's X configuration utility and try
to get better results. It is highly unlikely that you could hurt anything by
experimenting. Most modern monitors now have safeguards that prevent a
meltdown ;-)

If you over-do it though X may not be able to start. For this reason, I
prefer to use the "startx" way of starting X (see below) while 
"experimenting". This way if X crashes, the display manager (GUI login) will
not loop and cause you severe headaches. startx just gracefully goes back to
a text console screen, where an error message may be visible. 

Another way of tweaking monitor related settings is with XFree86's xvidtune
program. This is run interactively and can be used to adjust various settings
(see man page). The simple dialog box has sliders and buttons that allow user
input and adjustment. The top part has horizontal monitor settings on the
left, and vertical settings on the right. The buttons just below the sliders
can be used to adjust each. 

This is sometimes used to adjust the viewable screen area, such as to center
it, or increase its size to fill the monitor's viewport. When xvidtune is
launched, it defaults to the current settings. 

The bottom left corner has buttons that can "Apply" new settings, "Test" new
settings, or "Show" current settings (i.e. dump to screen), among other
things. Any changes made here are not saved. If new settings are "Applied",
it is just for the current session. Example output of xvidtune "Show": 

+--------------------------------------------------------------------------------+
| Vendor: Unknown, Model: Unknown                                                |
| Num hsync: 1, Num vsync: 1                                                     |
| hsync range 0:  30.00 -  70.00                                                 |
| vsync range 0:  55.00 - 120.00                                                 |
| "1400x1050"   122.00   1400 1488 1640 1880   1050 1052 1064 1082 +hsync +vsync |
|                                                                                |
|                                                                                |
+--------------------------------------------------------------------------------+

The last line is the "Modeline" being used to drive the current screen. See
The XFree86 Video Timings HOWTO, [http://www.linuxdoc.org/HOWTO/
XFree86-Video-Timings-HOWTO/index.html] http://www.linuxdoc.org/HOWTO/
XFree86-Video-Timings-HOWTO/index.html, for more on "Modelines".  

You can test modifications, and apply them to the current session. For
changes to be made permanent, they will have to be added manually to the 
"Monitor" section of XF86Config (or XF86Config-4 for v.4.x) with a text
editor. 

xvidtune will dutifully warn of you of the hazards of playing with the
monitor settings. It is unlikely you can hurt anything with modern monitors.
But it is best used to make minor adjustments. Use at your own risk! 
-----------------------------------------------------------------------------

3. Running X

Starting an X session is typically done in one of two ways: the X session is
started via a display manager (like xdm), and the user logs in at a GUI
screen. Or, the user starts X manually after logging in to a text console.
The latter is typically done with the startx command, which is a simple shell
script wrapper for xinit. X runs with root privileges in either case, since
it needs raw access to hardware devices. 

Typically, which method is used, is determined by the system "runlevel". The
default runlevel to launch at boot is generally set in /etc/inittab on Linux:

+---------------------------------------------------------------------------+
| # Run xdm in runlevel 5                                                   |
| x:5:respawn:/etc/X11/xdm -nodaemon                                        |
|                                                                           |
|                                                                           |
+---------------------------------------------------------------------------+

That would start xdm, and thus X, at runlevel 5. It will "respawn", if it
dies or is stopped for any reason. You can also use the "init" command to
change runlevels without rebooting (see man page). 

Let's look briefly at both approaches, and then some additional configuration
to set up the user's working environment. 
-----------------------------------------------------------------------------

3.1. startx

startx will start X by first invoking xinit. By itself, this would put you at
a blank, fuzzy looking, bare-bones desktop with no Window Manager loaded. 
xinit basically takes two sets of command line arguments: client
specifications (programs to run, etc), and server specifications (X server
options), separated by "--". If no client program is specified on the command
line, xinit will look for a .xinitrc file in the user's home directory, to
run as a shell script. If found, this then would in turn run whatever user
specified commands to set up the environment, or launch programs that the
file contained. If this file does not exist, xinit will use the following
initial command: 

+---------------------------------------------------------------------------+
|                                                                           |
| xterm -geometry +1+1 -n login -display :0                                 |
|                                                                           |
|                                                                           |
+---------------------------------------------------------------------------+

If no .xserverrc is found in the user's home directory, X itself will be
started with the following command: 

+---------------------------------------------------------------------------+
| X :0                                                                      |
|                                                                           |
|                                                                           |
+---------------------------------------------------------------------------+

As you see, this is not overly helpful as it just launches one xterm. The 
startx shell wrapper provides additional functionality and flexibility to 
xinit. startx will invoke xinit for us, and provide some simple configuration
options as well. You can also issue commands such as the following, for
instance:

+---------------------------------------------------------------------------+
|                                                                           |
| startx -- -dpi 100 -depth 16   #force X to 100 dots per inch              |
|                                #and colordepth of 16 (X v4 syntax)        |
|                                                                           |
|                                                                           |
+---------------------------------------------------------------------------+

Anything after the double dashes are passed as arguments directly to the X
server via xinit. In this example, you can force X to the resolution of your
preference, and still have it use the configuration files we will cover later
in this document. See the Xserver man page for more command line options. 

Instead of issuing the same command line every time, it is easier to use the
configuration files to store this type of information for us. 

If you take a look at the startx script (/usr/X11R6/bin/startx on my system),
you see it uses two default configuration files to help set up the X
environment: xinitrc and xserverrc. It looks first in /etc/X11/xinit/, for
the system wide files. It then checks the user's home directory for similar
files, which will take precedence if found. Note that the latter are Unix
style "dot" files (e.g. ~/.xinitrc), and are executable shell scripts. 

You normally would not want to edit the system wide files, but you can freely
copy these to your home directory as a starting point, or just start from
scratch. As you can tell by the names, one helps set up the X server, and one
sets up xinit by executing commands, preparing the environment and possibly
starting client programs like xterm or a Window Manager (yes, it's a client
too). 
-----------------------------------------------------------------------------

3.1.1. xserverrc

As with all XFree86 configuration files, this is a plain text file, and is
usually a simple, one line statement to start the X server. It can include
any valid command line options supported by your X installation. If you
always start X with your own options, this should be easier than typing the
options each time. One possible ~/.xserverrc: 

+---------------------------------------------------------------------------+
| exec X :0 -dpi 100 -nolisten tcp                                          |
|                                                                           |
|                                                                           |
+---------------------------------------------------------------------------+

This will start X on display :0, the first "display", at a dots-per-inch
resolution of 100, and disables TCP connections. See the Xserver man page for
other valid options. This is just an example. 
-----------------------------------------------------------------------------

3.1.2. xinitrc

xinitrc is used to set up a suitable X environment, and to launch other
programs, a.k.a "clients" that we may want available as soon as X is started.
You likely have a system wide xinitrc to start a predefined set off programs.
To customize this, create your own in your home directory. Name it .xinitrc,
make sure it is an executable script, and chmod +x. An example (slightly
modified from the original on my system): 

+---------------------------------------------------------------------------+
|#!/bin/sh                                                                  |
|# $XConsortium: xinitrc.cpp,v 1.4 91/08/22 11:41:34 rws Exp $              |
|                                                                           |
|userresources=$HOME/.Xresources                                            |
|usermodmap=$HOME/.Xmodmap                                                  |
|                                                                           |
|# merge in defaults and keymaps                                            |
|if [ -f $userresources ]; then                                             |
|    xrdb -merge $userresources                                             |
|fi                                                                         |
|                                                                           |
|if [ -f $usermodmap ]; then                                                |
|    xmodmap $usermodmap                                                    |
|fi                                                                         |
|                                                                           |
|if [ -z "$BROWSER" ] ; then                                                |
|        # we need to find a browser on this system                         |
|        BROWSER=`which netscape`                                           |
|        if [ -z "$BROWSER" ] || [ ! -e "$BROWSER" ] ; then                 |
|        # not found yet                                                    |
|                BROWSER=                                                   |
|        fi                                                                 |
|fi                                                                         |
|if [ -z "$BROWSER" ] ; then                                                |
|        # we need to find a browser on this system                         |
|        BROWSER=`which lynx`                                               |
|        if [ -z "$BROWSER" ] || [ ! -e "$BROWSER" ] ; then                 |
|        # not found yet                                                    |
|                BROWSER=                                                   |
|        else                                                               |
|                BROWSER="xterm -font 9x15 -e lynx"                         |
|        fi                                                                 |
|fi                                                                         |
|                                                                           |
|export BROWSER                                                             |
|                                                                           |
|# start some nice programs                                                 |
|if [ -f $HOME/.Xclients ]; then                                            |
|    exec $HOME/.Xclients                                                   |
|else                                                                       |
|    xclock -geometry 50x50-1+1 &                                           |
|    xterm -geometry 80x50+494+51 &                                         |
|    if [ -f /usr/X11R6/bin/fvwm ]; then                                    |
|        exec fvwm                                                          |
|    else                                                                   |
|        exec twm                                                           |
|    fi                                                                     |
|fi                                                                         |
|                                                                           |
|#eof                                                                       |
|                                                                           |
|                                                                           |
+---------------------------------------------------------------------------+

Briefly, what this script does, is set up our working environment, with 
xmodmap (keyboard) and xrdb (application resource settings). More on these
below. Then the shell variable $BROWSER is set for a GUI environment
(Netscape in this example) so that any applications that might expect this,
have a reasonable choice available. Then the presence of the file Xclients is
checked, both as a system wide file and in the user's home directory. In this
particular example, this is where any client applications are to be started,
including a Window Manager (see below). These could just have as easily been
started here if we had wanted to. If an Xclients file can't be found, then a
Window Manager is started for us. Either fvwm, if available, or XFree86's
minimalist twm if not. If for some reason, neither of these can be started,
the script would exit, and X would fail to start. 
-----------------------------------------------------------------------------

3.1.3. Xclients

Everything up to this point has followed pretty much a standard and
predictable sequence of events. To summarize, we have invoked startx, which
in turn invoked xinit, which has parsed xinitrc for initial settings. Most
Linuxes should follow this same sequence, though the various values and
settings may differ. 

We now are at the last link in the chain where the user normally would
specify his or her preferences, including the Window Manager and/or desktop
environment to be used. The system will provide sane, though possibly
uninteresting, defaults if the user has not done so. Presumably, this is why
you are here ;-) 

The Window Manager, or desktop environment, is typically the last application
started. If you want other programs (like xterm) started, they should be
started before the Window Manager and "backgrounded" with an "&". This can
all be done in the user's ~/.xinitrc. Or as in the above example, the actual
applications are started from yet another script. Let's look at one short,
hypothetical such script, .Xclients: 

+----------------------------------------------------------------------------+
|                                                                            |
|#!/bin/bash                                                                 |
|# ~/.Xclients, start my programs.                                           |
|                                                                            |
|xset s off s noblank                                                        |
|xset m 30/10 4                                                              |
|xset r rate 200 40                                                          |
|                                                                            |
|xscreensaver &                                                              |
|rxvt -geometry 80x50-50+150 &                                               |
|                                                                            |
|echo Starting Window Manager...                                             |
|                                                                            |
|if [ -x /usr/X11R6/bin/wmaker ]; then                                       |
|  echo `date`: Trying /usr/X11R6/bin/wmaker... |tee -a ~/.wm-errors 2>&1    |
|  exec /usr/X11R6/bin/wmaker >> ~/.wm-errors 2>&1                           |
|fi                                                                          |
|                                                                            |
|echo `date`: Failed, trying fvwm... |tee -a ~/.wm-errors 2>&1               |
|                                                                            |
|# let's try regular fvwm (AnotherLevel doesn't work with fvwm1).            |
|if [ -n "$(type -path fvwm)" ]; then                                        |
|  # if this works, we stop here                                             |
|  exec fvwm >> ~/.wm-errors 2>&1                                            |
|fi          
Results 1 - 1
Help - FTP Sites List - Software Dir.
Searching half a billion files worldwide
© 1997-2009 MARUHN Internet Solutions