Lancer X

Lancer X - Généralités

Il y a deux grandes façons de lancer X au démarrage du système : à partir de la console ou via un gestionnaire de connexion graphique. Le choix entre l'une ou l'autre méthode dépend du niveau d'exécution (anglais runlevel) déterminé dans le fichier /etc/inittab pour le démarrage du système. La ligne :


demande au système de démarrer en mode console. La ligne :


vous amène tout droit à l'écran de connexion de X. Ce dernier cas de figure correspond à la situation par défaut dans une distribution Mandriva. Vous pourrez alors choisir dans un Menu "Type de session" quel serveur X vous souhaitez lancer (KDE, GNOME ou IceWM). Un menu vous offre aussi de démarrer finalement en mode console.

Si vous avez modifié votre inittab de façon à démarrer en mode console (ce qui peut être utile dans quelques rares cas particuliers : si vous avez des ennuis avec votre interface graphique ou si votre machine dispose de ressources très très limitées), alors vous vous retrouverez dans une console texte (appelée aussi parfois console tty). Vous disposerez, à vrai dire, de 6 consoles de ce type, entre lesquelles vous pourrez circuler en pressant la combinaison de touches Alt+flèche droite ou gauche. Vous devrez d'abord vous connecter en donnant votre identifiant et vore mot de passe. Si vous souhaitez en définitve repasser en mode graphique, connectez-vous sous root et lancez la commande :

init 5

qui fera redémarrer le système en mode graphique, quelle que soit la valeur choisie dans /etc/inittab pour le niveau d'exécution au démarrage.

On peut modifier le paramétrage par défaut, en éditant le fichier /etc/inittab' directement dans un éditeur de texte lancé sous root, soit par l'entremise du Centre de contrôle Mandriva Linux ('Boot' - 'Boot Config' - 'Launch the X Window system at start').

Index de la section

Configuration Files

The X Window System consists of two components: a client and a server. Because of this architecture, there are two sets of configuration files, one set for the client side and one set for the server side. Client side configuration can be overruled by special files in a user's home directory.

Client side configuration:

  • '/etc/X11/Xsession': This script determines which window manager or desktop environment is run on X. Settings can be overruled by '.xinitrc' or '.xsession' (although the later is rarely used these days) or by options to the 'startx' command (see below).
  • '/etc/X11/wmsession.d/': This directory contains the start scripts for the window managers and desktop environments installed on this system. Sessions can be checked, added and deleted via the 'chksession' command. See man chksession.
Server side configuration:
  • '/etc/X11/XF86Config-4': This file contains the hardware configuration and settings like default screen resolution or color depth. Usually you do not edit it by hand but with tools like 'XFdrake'. See man XF86Config.
  • '/etc/X11/xdm/Xservers': This file contains the command line to start up the X server(s). Might be interesting when you want to start more than one server or turn off X' network capatibilities for security reasons ('-nolisten' option). A list of options and syntax is available in man Xserver.
Other configuration files:
  • '/etc/X11/fs/config': The configuration file for the 'xfs' font server. See man xfs.
  • '/etc/X11/Xressources' and files in '/etc/X11/app-defaults': These files determine the appearance of some of programs which are part of the XFree86 suite (like 'xterm'). Settings can be overruled by '~/.Xdefaults'. Since almost everybody uses GTK+ or Qt substitutes these days, these are of a rather marginal interest. See man xrdb.
  • '/etc/X11/Xmodmap' contains some default key mappings for the 'Backspace' and the 'Windows' keys. See the article on Keyboard on X.
  • '/etc/X11/~XftConfig' contains the configuration for anti-aliasing text via the RENDER extension. See the article on X Fonts.
section index

Starting From Console

After logging in, you are in your home directory. In order to start X, enter


Startup in detail

'startx' is but a starter script for 'xinit', the X initializing program.
After initializing the server with the options listed in '/etc/X11/xdm/Xservers', 'xinit' looks for a file '.xinitrc' in your home directory. If there isn't such a file, it looks up its own configuration file '/etc/X11/xinit/xinitrc'. This file in turn points 'xinit' to '/etc/X11/Xsession', the central startup configuration script.

  • '/etc/X11/Xsession' sets a default background color, starts the SSH agent if available, processes user preference files like '.Xresources' and '.Xdefaults' and sets the $BROWSER variable.
  • It then executes
    /usr/sbin/chksession -l
    to see which window managers and desktop environments are available on the system. 'chksession' gets this list from the scripts in '/etc/X11/wmsession.d', the order is determined by the two digits in front of each file name.
  • Next the scripts in '/etc/X11/xinit.d' are processed (usually the menu update and some minor keyboard stuff).
  • The next bit checks if you have specified any window manager or desktop environment on the command line. If not, it checks if you've done so in a ~/.desktop file. If not, '/etc/sysconfig/desktop' is checked for a setting. If one of these steps is successful, the variable $DESKTOP is set.
  • The script the goes on to check if a XIM input server is needed (mainly for Asiatic languages) and if the 'first time wizard' should be launched.
After all that is done, the script finally starts the graphical environment in this order:
  • The window manager or desktop environment specified in the $DESKTOP variable set above. The appropriate startup script in /etc/X11/wmsession.d is executed.
  • If the script failed to set the $DESKTOP variable,
    '/usr/sbin/chksession -F
    ' is executed. This prints the first available session entry which is then started.
  • If that fails, too, the script checks for the 'icewm' window manager and starts that window manager.
  • If 'icewm' shouldn't be installed either, it checks for 'icewm-light', then for 'twm' (XFree's own very basic window manager).


As you can see, you can influence the startup process in several ways:

  • By supplying options to the 'startx' command. There are two sets of options which can be passed via 'startx', options to the client and options to the server. Options to the client usually state the session name of window manager to use:
startx ~WindowMaker

starts X with the Window Maker window manager. Notice that you have to use the exact session name as listed by the /usr/sbin/chksession -l command. The second set of options is passed to the server. These include things like color depth or DPI settings. Available options are listed in man XF86Config. Server options are separated by a double dash:

startx ~WindowMaker –– -depth 16 -dpi 100

starts X with the Window Maker window manager and a color depth of 16 bit and a dot per inch setting of 100.
Options provided with 'startx' overrule all options specified elsewhere.

  • By writing an '.xinitrc' file. An .xinitrc file tells X which scripts or programs to execute and which window manager to start. Here's an example:
xmodmap ~/.Xmodmap<br> xterm &<br> exec wmaker

The first line runs a commandline utility to change the keymap.
The second starts an instance of the xterm terminal emulator. Notice the '&' at the end of the line, it is needed if you start graphical programs via '.xinitrc' to send those programs 'in the background'. Otherwise the startup process would simply hang as long until the program is terminated.
The last line uses the shell's 'exec' command, which replaces the current shell with the command which follows. This command is the executable name of the window manager (here Window Maker).

  • Via a '~/.desktop' file. Create a file with the name '.desktop' in your home directory with this line in it:

where session_name is the name of your preferred graphical environment as shown by /usr/sbin/chksession -l.

section index

Starting Graphically

Graphical logins are handled by so-called display managers. Mandrake Linux comes with three display managers: KDM (KDE Display Manager), GDM (GNOME Display Manager) and XDM (guess … ;-)), KDM being the default.

Display managers offer greater convenience when it comes to starting and leaving X sessions. They also allow remote session logins. Especially GDM offers a wealth of options. On the other hand they are consuming system resources during the whole X session and might pose a security risk when configured wrongly.

KDM is part of the 'kdebase' RPM, GDM comes in its own 'gdm' RPM and XDM is part of the XFree86 package. GDM does not require GNOME to be installed.

Startup in detail

If runlevel 5 is set as the default runlevel in '/etc/inittab', a special command for that runlevel is executed:

x:5:respawn:/etc/X11/prefdm -nodaemon

The syntax of this line is 'id:runlevel:action:command', in this case: when entering runlevel 5 (id 'x'), start a recurring process using the command '/etc/X11/prefdm -nodaemon'. The process 'recurs' in that it is restarted every time it terminates (i.e. if you log out of an X session, the display manager login window will reappear and you will not be dropped onto the console.).

'/etc/X11/prefdm' is a script which tries to determine which display manager you want to use. First it checks if 'autologin' is configured in '/etc/sysconfig/autologin'. If so, the configured EXEC command (usually '/usr/X11R6/bin/startx') is executed and the user will be put directly into their preferred environment. This can be configured via the 'Mandrake Control Center' ('Boot' - 'Boot Config').

If autologin is not activated, 'prefdm' checks '/etc/sysconfig/desktop' for the DISPLAYMANAGER variable (possible values: GDM, KDM or XDM). If this variable isn't set, it checks for the DESKTOP variable in the same file. If that variable is set to GNOME, GDM is assumed as the preferred display manager, if to KDE, KDM.

If none of these apply, the script checks for which display managers are installed and starts the first it finds. KDM is looked up first, then GDM and then XDM.


Both GDM and KDM can be configured via their configuration modules in the respective desktop command centers. Check their online help systems. The central configuration file for GDM is '/etc/X11/gdm/gdm.conf', KDM uses '/usr/share/config/kdm/kdmrc'.
GDM can also be configured as 'root' via the gdmconfig command or via the menu ('Configuration' - 'Boot and Init'). It offers much more configuration options than KDM, especially in regard to remote login options.
However, you should be very careful and considerate in regard to those options since a wrong configuration can make it very easy for intruders to take control of your system.

If you install GDM and are using KDE, remember to set


in '/etc/sysconfig/desktop' or otherwise the system will continue to use KDM.

section index

Autres ressources

Startx Marks The Spot
man inittab
man startx
man XF86Config
man xinit

Manuel de kdm
GDM Reference Manual in /usr/share/help/gnome

Revision / Modified: June 17, 2002
Author: Tom Berger

Legal: This page is covered by the GNU Free Documentation License. Standard disclaimers of warranty apply. Copyright LSTB and Mandrakesoft.

KB - Starting X
Version 1.15 modifié par ptyxs le 09/10/2006 à 15:51


en pt fr


Créateur: newimr le 2004/06/10 15:18
(c) Mandriva 2007