Certification Objective 6.06: The X Start Process

 < Day Day Up > 

You can configure the X Window interface to start automatically when your system boots, or you can choose to start the X Window System manually. You can set up this option in the /etc/inittab configuration file. If you select a text login, you'll have to start the Linux GUI with the startx command. If you select a graphical login, you can also select the graphical login manager of your choice.

Text Login Mode

To access a Linux system, you need to log in. In other words, you identify yourself to the system with a username and a password. But this requires a login program. When you log into Linux at a regular command line interface, the mingetty command calls up a login program that prompts you for your username and password. Six mingetty terminals are configured through /etc/inittab.

There are six active runlevels in Linux. The two of concern here are runlevels 3 and 5. If you start Linux in runlevel 3, you get a text login. If you start Linux in runlevel 5, you get a graphical login screen.

It's easy to change the default boot mode from the command line to X Window. Just edit the /etc/inittab file. Go to the line with the initdefault variable. To make Linux start the X Window System automatically when Linux starts, use your favorite text editor and change the line in /etc/inittab that reads




Of course, you can reverse this process. This change does not take effect until you reboot. If you are running as the root user, you can also use the init command to switch between runlevel 5 and runlevel 3. Running this command:

# init 3

switches your display from X Window back to text terminal mode, whereas:

# init 5

switches you from text terminal mode to X Window. You can find more information on different runlevels and /etc/inittab in Chapter 4.

Display Managers: xdm, gdm, kdm

When you configure Linux to start from runlevel 5, you can log in through a special X Client, the display manager. The display manager is a fairly simple program; all it does is display a dialog box on the screen asking for your username and password. You can use any of three major display managers. The default display manager is the GNOME display manager, or gdm. To change your display manager, edit the prefdm shell script in the /etc/X11 directory, as shown in Figure 6-9.

click to expand
Figure 6-9: Set your preferred display manager in /etc/X11/prefdm.

Take the line that contains preferred= and add either kdm, gdm, or xdm for the KDE Display Manager, GNOME Display Manager, or X Display Manager, respectively. In the default RHEL 3 version of this file, it's on line 25.

How you start the X Window System affects its behavior. Assume you start X Window through one of the graphical display managers. When you exit an X Window session, you're returned to the same display manager. To continue, you would need to log in again.

The default behavior for the gdm window manager is to launch a GNOME session for you. The kdm window manager by default launches a KDE session. However, you can start GNOME or KDE from either login manager.

Both the GNOME and KDE environments use their own startup files. Through the use of option buttons, both the GNOME and KDE display managers allow you to choose the desktop environment you wish to start. From the GNOME display manager, click the Session menu. This starts a window where you can select from several desktop options, as shown in Figure 6-10.

click to expand
Figure 6-10: The GNOME display manager, gdm

From the KDE display manager, click the drop-down text box adjacent to Session Type, as shown in Figure 6-11. You can then select the desired desktop.

click to expand
Figure 6-11: The KDE display manager, kdm

You can even set up the generic xdm window manager, which gives you the login screen shown in Figure 6-12.

click to expand
Figure 6-12: The xdm login screen

If you log in using a display manager, X Window starts somewhat differently when compared to using startx. When you run startx, the X Window runs as a child process of your text-based login shell. Even though the X Window System is running, Linux is still at runlevel 3. After you exit the X Window System, you still have to log out of this shell to terminate your login session.

Exam Watch 

If the startx command doesn't successfully start the GUI from the command line in runlevel 3, check for a working xfs server in that runlevel. Unless you're already in runlevel 5, it doesn't matter if you've set xfs to start in runlevel 5.

Analyzing startx

You've already seen that you can start the Linux GUI with the startx command. This starts the X Server and switches your display into graphics mode. It also runs through a series of configuration files which prompt Linux to start your selected desktop and other desired applications. In this section, we'll look at how startx actually works.

On The Job 

The startx command is actually a shell script that serves as a front end to the xinit command. The default location for both the startx and xinit is the /usr/X11R6/bin directory.

There are a number of configuration files which can help you customize the behavior of your X Window session. These are hidden files that you can install into user's home directories. If startx doesn't find a particular configuration file in your home directory, it uses a default version of the same file. Let us start our analysis with two of the first lines in the startx script:

userclientrc=$HOME/.xinitrc sysclientrc=/etc/X11/xinit/xinitrc

When you start the X Window System with the startx command, the xinit program looks for a file to run named .xinitrc in your home directory. If the startx command cannot find $HOME/.xinitrc, it will read the /etc/X11/xinit/xinitrc configuration script. This file, in turn, runs either the file $HOME /.Xclients or, if that file doesn't exist, /etc/X11/xinit/Xclients.

A typical ~/.xinitrc file includes commands that start various X Clients. (Remember, the tilde (~) represents the home directory.)

On The Job 

As described earlier in this chapter, you can also configure X Clients to start when you start the GNOME desktop through the Sessions utility. Settings are stored in each user's home directory, in the ~/.gnome2/session-manual file.

Let me illustrate a simple ~/.xinitrc file:

#!/bin/bash xterm & xclock -geometry 200x200-20+20 & xcalc -geometry 300x300-20-20 & exec twm

The first line sets bash as the shell for this script. The next line starts an xterm terminal client. The following line starts xclock, with a specific size and location. The line after that brings up an X Window calculator, also with a specific size and location. Notice that the first three command lines end with an ampersand (&). This is important; it tells the shell to run each command line and return control to the shell for this script. The final line uses the exec command to start the twm window manager. I illustrate the result in Figure 6-13; this supersedes any default desktop and X Clients which you may have otherwise configured.

click to expand
Figure 6-13: A GUI as configured through ~/.xinitrc

You can start other desktops through this file. You can substitute one of the following commands for exec twm:

exec gnome-session exec startkde

You can create an ~/.xinitrc file with a text editor of your choice. Once you've saved the file, startx executes the commands in this file, with the results shown in Figure 6-13.

Exam Watch 

There is more than one way to do many things in Linux, including the setup of default X Clients. Knowing these options can help you troubleshoot problems during the Red Hat exams.

Exercise 6-7: Customizing the startx Process

start example

In this exercise, we will configure the X Window System to use a customized .xinitrc file.

  1. If the X Window System is running, change to a text console by pressing CTRL-ALT-F1.

  2. If you see a login prompt, log in at the text console as root. Otherwise, press CTRL-C to stop the current X Window.

  3. If you logged in at the text console, stop the current X Window Server with the following command:

    # init 3
  4. Make sure you're in your home directory. Use your favorite text editor to create a .xinitrc file. If you're not sure what to do, use the sample file shown in the previous section.

  5. Start the X Window System with the following command:

  6. Your X Window session should automatically start the applications in your .xinitrc file.

  7. Exit from the twm desktop. Left-click on the desktop to bring up the twm main menu and click Exit.

  8. If you want to restore your original desktop settings, to allow you to start GNOME or KDE with the startx command, remove the .xinitrc file from your home directory.

end example

Now that you have seen how X Window Clients and the X Window Server work together, refer to the following Scenario & Solution for some common situations you may encounter, along with their solutions.

Table : Scenario and Solution

I'm having problems getting XFree86 to run on my hardware.

Check the Red Hat hardware support site. Run redhat-config-xfree86.

I want to use a different desktop environment.

Use the switchdesk command to change your desktop environment.

I want to stop the X Window System without rebooting Linux. When I try logging out, all I see is a graphical login manager.

Use the init 3 command to change the system runlevel to runlevel 3.

I'm having problems starting an X Client.

Check that the DISPLAY variable is properly set with the following command:
# export DISPLAY=localhost:0.0 Check for underlying network problems. Check X security problems.

My X Window display is acting strangely and I can't log in.

Switch to a virtual console and log in. Check the error logs. See if your X Font Server (xfs) is running. If it isn't, check for errors in ~/.xsession-errors and /var/log/messages. Make sure your /tmp and /home directory partitions are not full. As a last resort, rerun redhat-config-xfree86.

 < Day Day Up > 

RCHE Red Hat Certified Engineer Linux Study Guide[c] Exam (Rh302)
RCHE Red Hat Certified Engineer Linux Study Guide[c] Exam (Rh302)
ISBN: 71765654
Year: 2003
Pages: 194

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net