-->
Previous Table of Contents Next


Starting X Automatically on Login

If you don’t set up xdm, you’ll need to type in startx after you login to get X and all these applications in your .xinitrc file started. If you don’t like to enter startx every time you login, and you’re sure that you want to run X every time you login, you can put the startx command in your .login or .profile file (depending on the shell you use, csh or ksh). If you do, be sure that you’re running from the console only. Otherwise, the .login or .profile file will error out if they get run from elsewhere (such as when you login over a serial line or from another virtual terminal).

The way to check for this is to check the result of the tty program. The tty program returns the current device file used for your terminal. When run from an xterm shell window, tty will print out something like /dev/ttyp1 (for the first pseudo-terminal device). But, when run from the console (from the first virtual terminal), tty will print out /dev/tty1. When run from the second virtual terminal, tty prints out /dev/tty2 so we can check for /dev/tty1.

To do this, we can enter tty at the console (before starting X):


     $ tty

     /dev/tty1


NOTE:  Use the value tty returns for you, not necessarily the value we received.

Armed with this information, you can edit your .login file (presuming you use the C shell, csh, as your shell) to add the following lines:


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

     startx

  endif

This will start up X when you login at the console. You can also set up your account to log you out when you quit X. Most of the time, we begin X at login and quit X when we want to logout. If this fits your pattern, you can change the .login file to contain the following:


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

     startx

     logout

  endif

The X Font Server

The X font server is a special program that can scale fonts. This ability dramatically increases the already-prolific set of X fonts available on your system (use the xlsfonts command to list these fonts). To get the font server up and running, you must:

  Configure the font server and tell it where to get fonts.
  Configure the font server to start up before X does.
  Configure the X server to communicate with the font server.

To configure the font server, we need to tell it where to find the scalable fonts. Luckily, Linux comes with a workable preconfigured file, /usr/X11R6/ lib/X11/fs/config.

To start the font server, use the xfs (short for X font server) command. Enter the following command as root:


  # xfs -port 7000 &

This uses the default configuration file, /usr/X11R6/lib/X11/fs/config, and runs on TCP/IP port 7000 (an arbitrary port to which the X font server defaults).

Once started, we can verify that the font server is running by using the fsinfo command:


     gilbert:/$ fsinfo -server hostname:port

You need to fill in the hostname and port number. For example, with a hostname of eric and the default port number of 7000, the command would be:


     gilbert:/$ fsinfo -server eric:7000

You should see output like the following:


     name of server: eric:7000

     version number: 2

     vendor string:  X Consortium

     vendor release number:  6000

     maximum request size:   16384 longwords (65536 bytes)

     number of catalogues:   1

             all

     Number of alternate servers: 0

     number of extensions:   0

Once you verify that the font server is running, you can set up XFree86 to communicate with the font server. This is necessary so that X applications can take advantage of the font server’s fonts.

To get the X server ready to accept the font server, you need to adjust its font path, or fp. Enter the following commands:


     gilbert:/$ xset +fp tcp/eric:7000

     gilbert:/$ xset fp rehash

In your case, you need to replace eric with your system’s hostname. The first command tells the X server to use a TCP/IP port as a sort of font directory; the tcp/hostname:port syntax is the standard way to do this. The second command tells the X server to query again for all the available fonts.

If you’re running xdm (see “Starting X at Boot-Up” earlier), you should stop that, verify that things work manually, and then set up xdm again. Problems with the font server may cause X to quit. If X quits, this may prevent an X-based login, leaving you in an unhappy situation.


Previous Table of Contents Next