Top

A Linux User Reference

Search tips
  • search ignores words that are less than 4 characters in length
  • searches are case insensitve
  • if a search does not return anything try it in Boolean mode then Query expansion mode by checking the appropriate radio button e.g. searching for 'cron' in just the Administration category returns nothing - presumably because the 50% threshold is reached. Boolean mode ignores this threshold so a search for 'cron' returns several hits
  • in Boolean mode preceding a word with a '+' means the result must include that word, a '-' means it must not
  • in Boolean mode '+crontab -anacron' means match articles about crontab that DO NOT mention anacron
  • to match a phrase e.g. 'manage system' check the Boolean mode radio button and enclose the phrase in quotes "some phrase ..."
  • in Query expansion mode the search context is expanded beyond the keywords you entered - relevancy of hits may well be degraded

DESKTOP UIS

X11 Window System

  • X-Windows hardware support

    Whatever the version it is important to ensure that your X-Windows is supported by the most recent video drivers. X-Windows is well supported particularly by X.org.

    Generic drivers exist that will generally get most X-Windows to work however propriety features and performance are generally lacking.

    Video chipset

    Video drivers are written for video chipsets not the cards they are on - check chipset is supported.

    Monitors

    Practically any monitor can be handled however the auto probe does not always get it right. To manually configure a Monitor need to know it's capabilities, at least

     Horizontal Sync (kHz)
     Vertical Refresh (Hz)
     Resolution (pixels)
    
    
  • X window components
    X Server

    A program that manages graphical output (the display) and input (keyboard, pointing devices ...) devices of a system with a physical console attached.

    Can be thought of as a combined graphics card, keyboard and mouse driver.

    X Client

    An program that requires the use of an X server to access input and output devices.

    The X server could be running locally (e.g. X Workstation) or remotely (e.g. X terminal connecting to an application server) on the network.

    Display Manager (DM)

    At it's most basic - GUI login application.

    It manages the X sessions on a local (logging into the system itself, an X workstation) or remote display (logging into another host, an application server, reachable on the network), user authentication and more.

    It is not the desktop environment - this is the job of the Window Manager which is called by a Display Manager.

    There are several different types of display managers available, xdm (the default Display Manager(DM) shipped with X11), gdm and kdm to name but a few well known ones - there are many more included less resource hungry ones such lightdm ...

    X Display Manager Control Protocol

    XDMCP is used for communication between the dsiplay manager and the X server. In essence the X server requests XDM via an xdmcp query, to provide a login prompt. There are three ways it can do this:

    Query type Server response
    Direct The X server contacts a named host requesting that XDM on that host to present a login prompt on its display
    Broadcast The X server sends out a broadcast request to the network. The the first server running XDM that responds to the broadcast will be the one to present the login prompt on its display.
    Indirect The X server contacts a named host asking it which other hosts it knows about on the network. The named host presents the user with a list of hosts to choose from. It initiates communications with the selected host resulting in the selected host presenting a login prompt on the X server's display.
    Application Server

    A system that provides applications (X clients) that an X Terminal may want to run (browsers, editors, window managers ...)

    Diskless X Terminal

    No local disk(s), network boots, gets everything from the server it connects to (network and system configuration, operating system and all applications).

    Dumb X Terminal

    Boots from its local disk into an operating system and starts the X server program - nothing more. A means to login to an application server somewhere on the network needs to be provided.

    X Workstation

    Similar to a dumb X terminal but provides the option of logging on to the local machine itself.

    Capable of becoming a standalone workstation with its own X server, GUI login prompt, Desktop and applications - pretty much a Desktop distribution.

    Window managers

    Window managers control the appearance of windows and provides the means by which the user can interact with them.

    There are many available for Linux - twm (X default), fluxbox, metacity, mwm, icewm, blackbox .. to name but a few.

    Selection of which window manager to run is usually stipulated in the last line of /etc/X11/xinit/xinitrc or ˜/.xinitrc or in /etc/X11/default-display-manager file.

    Configure fluxbox to run as the window manager - xinitrc

    .....
    exec fluxbox
    

    If not here then in 'default-display-manager' or even '/etc/X11/xinit/Xclients' which can also be used to specify which x-applications, window-manager to run.

    If '/etc/X11/default-display-manager' exists then it should go in there replacing whatever dm was there previously.

  • XDMCP is inherently INSECURE
    • X is not a very safe protocol for leaving on the net, XDMCP is even less so.

    • When using ensure that it is on a trusted internal network with no access to the Internet.

    • Such a set up may involve having a number of x-terminals and an application server on an internal lan segment or one interface of an application server is connected to the lan segment in which case it can be configured to only service X protocols coming from this lan segment.

    • Additional security can also be provided by an appropriately configured firewall on the application server i.e. aAdvised that you block the XDMCP port (normally UDP port 177) on your firewall unless you really need it.

    • TCP wrappers can add another layer of security via use of whitelists and blacklists (/etc/hosts.allow, hosts.deny files) where the name of the display manager e.g 'xdm', 'gdm', 'kdm', ...) is the service name.

  • Remote X clients

    For an x-application to send output to a remote host the DISPLAY environment variable must be set and exported.

    DISPLAY variable format: <host><:display<.>screen>
    
    Where - 
    <host>                 can be Hostname, FQDN or IP. If omitted localhost is assumed.
    <:display<.>screen>    is the display output is directed to. A single system can have many displays.
    
         screen            is optional. Used in multi-headed configurations
    

    Setting DISPLAY variable examples

    $ export DISPLAY=:0                (Default display on localhost)
    $ export DISPLAY=192.168.0.3:0.    (Default display on remote host)
    $ export DISPLAY=:1.2              (Third screen on second display on localhost - multiheaded)
    
  • Configuration file format
    xorg.conf, XF86Config

    There are various XFree86 configuration tools. In essence configuration requires the creation of the XF86Config file.

    Tool Description
    xf86config Text mode program, prompts user for configuration information and writes XF86Config file
    XF86Setup GUI program, starts a VGA server - allows selection of chipset, monitor, mouse, keyboard and writes XF86Config file
    xf86cfg GUI as XF86Setup, uses a block diagram approach (as opposed to menu driven) for configuration, writes XF86Config file

    Though different files there are common elements to their format.
    xorg.conf or XF86Config

    Section "section"
       Setting "value"
       ...
    EndSection
    Section "files"
       RgbPath    ".../X11/rgb"
       FontPath   "/usr/X11R6/lib/X11/fonts/75dpi"
       FontPath   "/usr/X11R6/lib/X11/fonts/100dpi"
       FontPath   "........"
    EndSection
    

    XF86Config (<4.0) uses different Section labels to those above. They are:

    "Files"           Contains font and RGB db paths
    "ServerFlags"     Contains X server options
    "Keyboard"        Contains keyboard configuration
    "Pointer"         Defines a pointing device e.g. mouse
    "Monitor"         Defines a monitor, a section per monitor
    "Device"          Defines one or more graphics cards, a section per device
    "Screen"          Pairs a Monitor with a Device, defines driver, screen resolution(s), 
                      colour depth, size, modes etc..
    

    XFree86Config (> 4.0) and X.org.conf sections

    "Files"           As earlier versions
    "ServerLayout"    Defines display, screen(s) and labels input devices. Ties together a 
                      screen with one or more input devices
    "Input Device"    A section per input device e.g. mouse, keyboard, touchpad ...
    "Monitor"         As earlier versions
    "Device"          Section defines video X-Windows, a section per device
    "Screen"          As earlier versions
    "Modules"         Additional modules to load
    

    Sample configuration - /etc/X11/xorg.conf

    Section "ServerLayout"
        Identifier     "Default Layout"
        Screen      0  "Screen0" 0 0
        InputDevice    "Keyboard0" "CoreKeyboard"
        InputDevice    "Mouse0" "CorePointer"
    EndSection
    
    Section "Module"
        Load           "glx"
    EndSection
    
    Section "ServerFlags"
        Option         "Xinerama" "0"
    EndSection
    
    Section "InputDevice"
        # generated from default
        Identifier     "Keyboard0"
        Driver         "kbd"
    EndSection
    
    Section "InputDevice"
        # generated from default
        Identifier     "Mouse0"
        Driver         "mouse"
        Option         "Protocol" "auto"
        Option         "Device" "/dev/psaux"
        Option         "Emulate3Buttons" "no"
        Option         "ZAxisMapping" "4 5"
    EndSection
    
    Section "Monitor"
        Identifier     "Monitor0"
        VendorName     "Unknown"
        ModelName      "CMO CMC 19AW"
        HorizSync       30.0 - 82.0
        VertRefresh     56.0 - 76.0
    EndSection
    
    Section "Device"
        Identifier     "Device0"
        Driver         "nvidia"
        VendorName     "NVIDIA Corporation"
        BoardName      "GeForce 8500 GT"
    EndSection
    
    Section "Screen"
        Identifier     "Default Screen"
        Device         "Configured Video Device"
        Monitor        "Configured Monitor"
        DefaultDepth    24
    EndSection
    
  • Generate an xorg.conf file
    /usr/bin/X

    Xorg requires the creation of /etc/X11/xorg.conf file. Need to be root, the X server command probes for devices and creates a xorg.conf.new file in root's home directory. Test and modify to suit.

    Generate a new xorg.conf file

    # /usr/bin/X -configure
    

    Test the new config file

    # /usr/bin/X -config /root/xorg.conf.new
    # vi /root/xorg.conf.new                           (Edit, customise, save, retest as above)
    # cp /root/xorg.conf.new /etc/X11/xorg.conf        (To use by default)
    
  • X video mode tuner
    /usr/bin/xvidtune

    Video mode tuner for Xorg. Can adjust the display to the monitor. Is similar to a monitor's controls. See man pages for more information.

  • Display X window information
    /usr/bin/xwininfo

    A utility for displaying information about windows.

    Basic usage

    $ xwininfo
    
    xwininfo: Please select the window about which you
              would like information by clicking the
              mouse in that window.
    
    xwininfo: Window id: 0x2a00004 "mark@mark-Lenovo-G585: /etc/default"
    
      Absolute upper-left X:  357
      Absolute upper-left Y:  179
      Relative upper-left X:  1
      Relative upper-left Y:  26
      .....
    
  • Display X server information
    /usr/bin/xdpyinfo
    • predefined communications parameter/values
    • types of screens and visuals that are available
    xdpyinfo [-display displayname] 
             [-queryExtensions]
             [-ext extension-name]
    

    Basic usage

    $ xdpyinfo | head -n 8
    name of display:    :0
    version number:    11.0
    vendor string:    The X.Org Foundation
    vendor release number:    11303000
    X.Org version: 1.13.3
    maximum request size:  16777212 bytes
    motion buffer size:  256
    bitmap unit, bit order, padding:    32, LSBFirst, 32
    .....
    
  • Query X configuration information of DRI drivers
    /usr/bin/xdriinfo

    Query configuration information of DRI drivers. If no command argument is specified it lists the names of the direct rendering drivers for all screens.

    The DISPLAY environment variable holds the default display.

    xdriinfo [-display displayname] [command]
    
    Valid commands:
     nscreens                 Print the number of screens.
     driver screen            Print the name of the direct rendering driver for screen.
     options screen|driver    Print the XML document describing the configuration options
                              of a driver.  The driver can be specified directly by 
                              driver name or indirectly by screen number. If the driver 
                              name is specified directly then no X connection is needed.
    

    Command examples

    $ xdriinfo
    Screen 0: r600
    
    $ xdriinfo options 0
    <driinfo>
    <section>
    <description lang="en" text="Performance"/>
    <description lang="de" text="Leistung"/>
    <description lang="es" text="Rendimiento"/>
    ..... 
    
  • Screen configuration utility
    /usr/bin/xrandr

    Used to set the size, orientation and or reflection of the outputs for a screen. It can also set the screen size.

    Display supported screen resolutions

    $ xrandr
    Screen 0: minimum 320 x 200, current 1366 x 768, maximum 8192 x 8192
    LVDS connected 1366x768+0+0 (normal left inverted right x axis y axis) 344mm x 194mm
       1366x768       60.0*+
       1280x720       59.9  
       1152x768       59.8  
       1024x768       59.9  
       800x600        59.9  
    .....
    

    Change screen resolution for current session

    # xrandr -s 1280x800
    

    Change screen resolution for each session (per user)

    # echo "xrandr -s 1280x800" >> &tilde;/.xprofile
    

    NB use of '-s' , though still supported, is the older v1.1 syntax.'

    Check version

    $ xrandr -v
    xrandr program version       1.3.5
    Server reports RandR version 1.4
    
  • X server files, version
    Directory Contents
    /usr/bin X server and X clients
    /usr/X11R6 If exists is often a symbolic link to /usr/bin
    /usr/include Files needed to develop X clients and graphics e.g. icons
    /usr/lib Required libraries for X server and clients
    /usr/lib/X11 Fonts, default client resources, system resources
    /usr/lib/modules Graphics drivers and X server modules

    Determine X version (XFree86 and X.org) - /usr/bin/X

    $ /usr/bin/X -version
    X.Org X Server 1.6.0
    Release Date: 2009-2-25
    X Protocol Version 11, Revision 0
    
  • Starting the X server

    The X server is usually started at boot time either via /etc/inittab or other initialisation script(s).

    If not started automatically it can be started via the command line using either 'xinit' or it's front-end 'startx'.

    X Window System initialiser - /usr/bin/xinit

    Start the X Window System server and a first client program on systems that cannot start X directly from /etc/init or in environments that use multiple window systems. When this first client exits, xinit will kill the X server and then terminate.

    xinit [[client] options ...]
          [-- [server] [display] options ...]
    
    • If no specific client program is given on the command line, 'xinit' will look for a file in the user's home directory called .xinitrc to run as a shell script to start up client programs.

    • If no such file exists, 'xinit' will use the following as a default:

       xterm  -geometry  +1+1  -n  login  -display  :0
      
    • If no specific server program is given on the command line, 'xinit' will look for a file in the user's home directory called *.xserverrc~ to run as a shell script to start up the server.

    • If no such file exists, xinit will use the following as a default:

       X  :0
      

    Some Man page examples:

    Start up a server named X and run the user's '.xinitrc' if it exists else start an xterm

    $ xinit
    

    Start a specific type of server on an alternate display

    xinit -- /usr/local/bin/Xqdss  :1
    

    Start up a server named X and append the given arguments to the default 'xterm' command - ignores '.xinitrc'

    $ xinit -geometry =80x65+10+10 -fn 8x13 -j -fg white -bg navy
    

    Use the command '.Xsun -l -c' to start the server and append the arguments '-e widgets' to the default 'xterm' command

    $ xinit -e widgets -- ./Xsun -l -c
    

    Start a server named X on display 1 with the arguments '-a 2 -t 5'

    $ xinit /usr/ucb/rsh fasthost cpupig -display ws:1 --  :1 -a 2 -t 5
    

    It will then start a remote shell on the machine 'fasthost' in which it will run the command 'cpupig', telling it to display back on the local workstation.

    Determine X server to run - /etc/X11/xinit/xserverrc

    #!/bin/sh
    
    # To determine which X server to run xinit looks first for $(HOME)/.xserverrc, 
    # failing that /etc/X11/xinit/xserverrc
    
    # $Id: xserverrc 189 2005-06-11 00:04:27Z branden $
    exec /usr/bin/X11/X -nolisten tcp
    

    Man page's example - ˜/.xinitrc

    # When xinit/startx is called it determines which client to run by looking for 
    # $(HOME)/.xintrc, if this is not found it uses /etc/X11/xinit/xinitrc.
    # xinitrc sources /etc/X11/Xsession 
    
    xrdb -load $HOME/.Xresources
    xsetroot -solid gray &amp;
    xclock -g 50x50-0+0 -bw 0 &amp;
    xload -g 50x50-50+0 -bw 0 &amp;
    xterm -g 80x24+0+0 &amp;
    xterm -g 80x24+0-0 &amp;
    twm
    
    # Starts a clock, several terminals and leaves the window manager 
    # running as the 'last' application.
    

    Ubuntu default (system wide) - /etc/X11/xinit/xinitrc

    #!/bin/bash
    # $Xorg: xinitrc.cpp,v 1.3 2000/08/17 19:54:30 cpqbld Exp $
    
    # /etc/X11/xinit/xinitrc
    #
    # global xinitrc file, used by all X sessions started by xinit (startx)
    
    # invoke global X session script
    . /etc/X11/Xsession
    
  • X environment variables

    The following are primarily used by 'xinit' ('startx') which is called by the Display Manager - xdm, gdm, kdm .. after a successful login.

    OPTIONFILE      = /etc/X11/Xsession.options
    SYSRESOURCES    = /etc/X11/Xresources
    USRRESOURCES    = $HOME/.Xresources
    SYSSESSIONDIR   = /etc/X11/Xsession.d
    USERXSESSION    = $HOME/.xsession
    USERXSESSIONRC  = $HOME/.xsessionrc
    ALTUSERXSESSION = $HOME/.Xsession
    ERRFILE         = $HOME/.xsession-errors
    
  • Using 'startx' to initialise an X session

    'startx' is a front-end to 'xinit' and can accept the same arguements though is usually started without arguments.

    /usr/bin/startx [[client] options ...]
                    [-- [server] [display] options ...]
    

    Start an X session

    # startx
    
  • Change the Default Color Depth and dpi
    /usr/bin/startx
    # startx -- -depth 16 -dpi 100
    

    -- denotes the end of client params and start of server params

  • Install, remove and list X fonts
    /usr/bin/mkfontdir, xset, xlsfonts

    The Default install fontpath is compiled into the server.

    Application Default font install path
    x.org /etc/X11/fonts and /usr/share/fonts/X11/
    XFree86 /usr/X11R6/lib/X11/fonts/

    Additional fontpaths can be added via the config file's [Files] section using the FontPath directive. It is usual to install font files in separate directory(s) to the system installed fonts - preserve in the event of updates, upgrades.

    Add additional font directories and create indexes of fonts they contain

    # mkfontdir [options] [directory name ...]
    

    See the man pages for a full explanation - basically 'mkfontdir' searches for fonts in each directory supplied and indexes them.

    Add font(s) dynamically - /usr/bin/xset

    xset [- | +]fp[- | +] <fontpath, list, ...>
    

    '+fp' prepends fontpath to the beginning of an existing list, 'fp +' appends. '-fp' or 'fp-' removes fontpaths from ann existing list.

    'xset' can be used to set a variety user preferences - see man pages.

    List X server fonts - /usr/bin/xlsfonts

    $ xlsfonts | head -n 5
    -arabic-newspaper-medium-r-normal--0-0-100-100-p-0-iso10646-1
    -arabic-newspaper-medium-r-normal--32-246-100-100-p-137-iso10646-1
    -bitstream-bitstream charter-bold-i-normal--0-0-0-0-p-0-adobe-standard
    -bitstream-bitstream charter-bold-i-normal--0-0-0-0-p-0-ascii-0
    -bitstream-bitstream charter-bold-i-normal--0-0-0-0-p-0-iso10646-1
    
    Scalable fonts

    These font files do not usually include the X font name, the file fonts.scale can be used to name the scalable fonts in the directory.

    The fonts listed in it are copied to fonts.dir by 'mkfontdir'.

    fonts.scale has the same format as the fonts.dir file, and can be created with the 'mkfontscale' program.

  • X Font server
    • A font server offloads the x-server's font rendering work to clients.
    • Not part of the default installation - if using require 'xfs' package to be installed.

    Server configuration examples - /etc/X11/fs/config

    Client-limit = 8                                # allow 8 max clients to connect to 
                                                    # this font server
    Clone-self = on                                 # start a new font server when max 
                                                    # clients is reached
    Catalogue = /usr/X11R6/lib/X11/fonts/75dpi,     # ',' separated list of fonts to server
                /usr/X11R6/lib/X11/fonts/100dpi,    # Equivalent to FontPath in xorg.conf
                ........
    

    Enable Font Server on local host - /etc/X11/xorg.conf

    Section "Files"
       FontPath   "unix/:-1"                  # If the font server is also serving fonts to
                                              # remote hosts then this will be "unix/:7100"
    EndSection
    

    Uses a unix socket to connect to the font server on localhost.

    Use a font server on a remote Server - /etc/X11/etc/X11/xorg.conf

    Section "Files"
       FontPath   "tcp/remotehost:7100"       # Use tcp to make a connection to port 7100
                                              # on the remote font server
    EndSection
    

    This is the client's 'xorg.conf'.

    Start font server

    # xfs
    

    Usually automated to start at boot sfrom within 'init' style script, so something like '/etc/init.d/xfs [start|stop|...]' would be more appropriate.

  • Manage fonts with 'fontconfig' package

    The 'fontconfig' package

    • contains a font configuration and customisation library
    • provides a list of all the fonts available on a GNOME Desktop system
    • makes fonts managed by defoma available to fontconfig applications

    The package contains:

    Program Description
    fc-cache a program to maintain the fontconfig cache.
    fc-list a sample program to list installed fonts.
    fc-match a program to test the matching rules.
    fc-cat a program to dump the binary cache files in string form.

    Font listing tool - /usr/bin/fc-list

    $ fc-list | head -n 3
    /usr/share/fonts/truetype/tlwg/TlwgTypo-Bold.ttf: Tlwg Typo:style=Bold
    /usr/share/fonts/truetype/droid/DroidNaskh-Bold.ttf: Droid Sans:style=Bold
    /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique
    
    $ fc-list -v | head -n 5
    Pattern has 21 elts (size 32)
        family: "TlwgMono"(s)
        familylang: "en"(s)
        style: "Bold"(s)
        stylelang: "en"(s)
    

    List the first 5 oblique style fonts on the system

    $ fc-list :style=oblique | head -n 5
    /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans-Oblique.ttf: DejaVu Sans:style=Oblique
    /usr/share/fonts/truetype/tlwg/Loma-Oblique.ttf: Loma:style=Oblique
    /usr/share/fonts/truetype/tlwg/TlwgTypo-Oblique.ttf: Tlwg Typo:style=Oblique
    /usr/share/fonts/truetype/tlwg/Kinnari-Oblique.ttf: Kinnari:style=Oblique
    /usr/share/fonts/truetype/tlwg/Umpush-Oblique.ttf: Umpush:style=Oblique
    

    List all Droid* font familys

    $ fc-list : family  | grep Droid
    Droid Sans Mono
    Droid Serif
    Droid Sans
    

    ':' is a wildcard pattern matching all.

    $ fc-list Droid family
    

    or any variation of the pattern returns nothing - pattern matching ain't too hot since

    $ fc-list "Droid Sans" family 
    Droid Sans
    

    you need to know the full and exact (including case) name of the family you want listed.

    Main location for fonts

    $ ls -F /usr/share/fonts
    cmap/  truetype/  type1/  X11/
    
  • Host based access to X server
    /usr/bin/xhost

    Server access control program for X.

    Add, remove a host access

    xhost [+-] [name ...]
    
    Options:
     +                    Turn off access control - free for all
     -                    Turn on. Only hosts in list are permitted access
     +name                Add complete name or hostname to list - allow access
     -name                Remove complete name or hostname from list - deny access
    
                          A complete name has the syntax 'family:name' where the families are:
    
                          inet      Internet host (IPv4)
                          inet6     Internet host (IPv6)
                          dnet      DECnet host
                          nis       Secure RPC network name
                          krb       Kerberos V5 principal
                          local     contains only one name, the empty string
                          si        Server Interpreted
    

    xhost examples

    $ grep 192 /etc/hosts
    192.168.0.5     kali-laptop                          # add my laptop
    
    $ xhost + inet:kali-laptop                           # give it access to the X server on the desktop
    kali-laptop being added to access control list
    
    $ xhost + si:localuser:root                          # give root access, not to smart
    localuser:root being added to access control list
    
    $ xhost                                              # see what's up
    access control enabled, only authorized clients can connect
    SI:localuser:root
    INET:kali-laptop
    SI:localuser:mark
    
    $ xhost - si:localuser:root
    localuser:root being removed from access control list
    
    $ xhost - kali-laptop
    kali-laptop being removed from access control list
    
    $ xhost
    access control enabled, only authorized clients can connect
    SI:localuser:mark
    

    XDM authentication - MIT-MAGIC-COOKIE-1

    • XDM uses a 128 bit key/cookie stored in ˜/.Xauthority file.
    • Client needs to provide a matching cookie to gain access to the X server.
    • This is the preferred method on linux for controlling access to the X server.