-->
Previous Table of Contents Next


UNIX Run-Levels

Xdm is usually set to trigger what is called a run-level. With a few exceptions, run-levels in UNIX is an arbitrary concept that mostly follows ancient UNIX traditions. The run-level S implies a single-user stand-alone system.

In Linux, run-level 1 and higher are multiuser. This means that more than one user is allowed to login. On many systems, run-level 3 starts networking. This is also the default Linux run-level. Linux has special run-levels for power-fail (which shuts the system down) and the Vulcan death-grip (Ctrl-Alt-Backspace).

You can get some ideas about run-levels by looking in the /etc/inittab file. In /etc/inittab, one of the first entries will be something like the following:


  # Default runlevel.

  id:3:initdefault:


NOTE:  In Slackware 2.3 (and the first edition of this book), the Linux default run-level was 5. The default X run-level was 6. It has changed to 3 and 4, respectively. Now, run-level 6 will reboot the system, a great surprise if you want it to run X.

This states that the default system run-level is 3. When Linux boots up, it will boot into run-level 3. Later in the /etc/inittab file, you’ll find something like:


  x1:4:wait:/etc/rc.d/rc.4

This states that on entry to run-level 4, /etc/rc.d/rc.4 should be run. This file, then, starts up the X Display Manager, which presents an X login screen.

On our system, /etc/rc.d/rc.4 starts the following program:


  # Tell the viewers what's going to happen...

  echo "Starting up the X Window System V.11 R.6..."



  # Call the "xdm" program.

  exec /usr/X11R6/bin/xdm -nodaemon

This is what starts up xdm. To get xdm up and running, all you should really have to do is edit the /etc/inittab as root and change the following line:


     id:3:initdefault:

to


     id:4:initdefault:

That’s it. Everything else comes preconfigured. You may want to change the configuration, but you have a good start.

After making these changes, when you next boot Linux, you’ll boot into run-level 4 rather than run-level 3. The process of going into run-level 4 will start xdm, because of what’s in the /etc/rc.d/rc.4 file.

Before doing this, though, make a copy of /etc/inittab. You also should test xdm before setting the system to boot into it, because you always want to be able to boot Linux. (Making a mistake in /etc/inittab can result in a Linux that won’t boot.) To test xdm, you can type in the following command as root, to change to run-level 4 now:


     # init 4

This will jump you to run-level 4. Be patient; this command takes a while.

Be sure that X is not running when you do this. You should be logged in as root at the console.

If you set up your .login or .profile file to automatically call startx when you login (see “Starting X Automatically on Login” later), you must disable this first. These two methods for starting X conflict. Quit X and then comment out those lines you added to the .login or .profile file, for example:


     if ( `tty` == '/dev/tty1' ) then

     #    Commented out.

     #    startx

     endif

After a while, you should see a graphical login screen. It is best to test xdm using init 4 first, to see if everything is set up correctly. Try to login and see what happens. If it works, you’re in business and you can confidently modify the /etc/inittab file.

The xdm configuration files are in /usr/lib/X11/xdm. If you want to change the background color for the login screen, look in Xsetup_0 in that directory. You probably won’t have to edit much in /usr/lib/X11/xdm, especially for a stand-alone Linux system without X terminals on the network. (If your needs are more demanding, you’ll need to look into a book on X, such as The UNIX System Administrator’s Guide to X; see Appendix A for more on this.)

User Accounts Under Xdm

While you probably won’t have to edit any of the xdm system files in /usr/lib/X11/xdm, it’s likely you’ll have to edit files in your home directory. By default, xdm runs a file named .xsession from your home directory, instead of the .xinitrc that is run by startx (and xinit).

To create the .xsession file, you can start by copying your .xinitrc file to .xsession in your home directory. (Remember to put in the leading period on the filename in your home directory.) Then modify this file like you changed the .xinitrc file.

Here’s a copy of our .xsession file:


  #!/bin/sh

  userresources=$HOME/.Xresources

  usermodmap=$HOME/.Xmodmap

  sysresources=/usr/X11R6/lib/X11/xinit/.Xresources

  sysmodmap=/usr/X11R6/lib/X11/xinit/.Xmodmap



  # merge in defaults and keymaps



  if [ -f $sysresources ]; then

     xrdb -merge $sysresources

  fi



  if [ -f $sysmodmap ]; then

     xmodmap $sysmodmap

  fi



  if [ -f $userresources ]; then

     xrdb -merge $userresources

  fi



  if [ -f $usermodmap ]; then

     xmodmap $usermodmap

  fi



  # start some nice programs

  xsetroot -solid SteelBlue



  xterm -geom 80x32+264+0 -ls &

  xterm -geom 80x32+0+250 -ls &

  oclock -geom -7-7 &

  exec fvwm

If you don’t want to start up X at boot time, you may want to start X every time you login.


Previous Table of Contents Next