Red Hat Linux 7 Unleashed

Red Hat Linux 7 Unleashed

By William Ball

Starting X11 with the startx Command

The startx command is an easy way to start an X session if you're working on a single computer or boot Linux to runlevel 3 mode (X11, multiuser and networking enabled). There are other ways to start X (see the section Using xdm later in this chapter). The startx command is a handy shell script that will pass on command-line options to the X server for your X sessions.

The startx command is typically used to pass starting color-depth information to the X server, as well as to find client commands or options to run for the session (usually your .xinitrc file in your home directory; see the section The .xinitrc File).

If you use a similar Screen definition as in the previous section, the default X session will use 256 colors when you start your X session like this:

				
   # startx
			

If your video card and monitor support a greater color depth, you can start a 16 bitplanes-per-pixel (thousands of colors represented by 16 bits per pixel) X session using the -depth command-line option like this:

				
   # startx -- -depth 16
			

Unless you've used the DefaultColordepth option in your system's XF86Config file to set a specific color depth, using startx by itself will usually start an X session using 8-color bitplanes or 256 colors. Color values typically passed with the -depth option also include 24 and 32 for millions of colors.

Using the Console and Multiple X Sessions

You can also use startx to start multiple X11 sessions on the same computer, possibly using different window managers, and then navigate between the sessions using virtual consoles. Red Hat Linux supports up to six different login screens or consoles, accessed by pressing Alt+FX, where X is F1 through F6.

For example, if you log into Linux using a text-only console, you'll be at the first virtual console. After you log in, press Alt+F2; you'll then see another login prompt at the second console. To get back to your first login, press Alt+F1.

When you log into Linux and start an X11 session with startx, X uses a seventh virtual screen. Since you've started X from the first virtual console, this console will be unavailable for use. However, you can get to another virtual console, such as the second, by pressing Ctrl+Alt+F2 while in X11. You'll then see the Red Hat Linux login prompt. To go back to your X session, press Alt+F7. Using this approach, you can jump back and forth between your X session and different text consoles.

To use multiple X11 sessions at different color depths on different virtual consoles, first start a session with the startx command. After the X desktop appears, press Ctrl+Alt+F2 and log in to Linux again. If your graphics card supports thousands of colors again, use the startx command to start an X session. This time, however, include the :1, -fbbpp 16, and vt8 command-line options:

					
   # startx -- :1 -depth 16 vt8
				

The screen clears and you'll be running an X session with a different color depth! To jump to your other X11 session, press Ctrl+Alt+F7. To jump to another virtual console, press Ctrl+Alt+F3 (since the first and second consoles are in use). To jump back to your original X session, press Ctrl+Alt+F8.

The .xinitrc File

When you use the startx command to initiate an X session on your computer, details about which window manager to use or other X clients to start can be found in a file called .xinitrc in your home directory. A sample or template file called xinitrc is installed in the /etc/X11/xinit directory. You can copy this file to your home directory with the filename .xinitrc and modify it.

Although the default .xinitrc file contains shell script logic to load system resources or set different environment variables, you can define a simpler version from scratch, such as the one in Listing 4.2, which can be used to start 12 different X window managers. (For more information about several X window managers included on this book's CD-ROMs, see Chapter 5.)

Example 4.2. Sample .xinitrc File

# Sample .xinitrc file
#
# This .xinitrc file has configuration support for the following X11
# window managers: AnotherLevel, fvwm, fvmw2, KDE, twm, mlvwm, AfterStep
#                  WindowMaker, wm2, wmx, mwm, GNOME
#
# Use AnotherLevel's configuration of the fvwm2 window manager
# fvwm2 -cmd 'FvwmM4 -debug /etc/X11/AnotherLevel/fvwm2rc.m4'
#
# Use fvwm2
# fvwm2
#
# Use fvwm
# fvwm
#
					
					
					
# Use the K Desktop Environment
startkde
#
# Use twm - note: no longer needs an X terminal started!
# twm
#
# Use the mlvwm (Macintosh-like) window manager
# mlvwm
#
# Use AfterStep
# afterstep
#
# Use WindowMaker
# exec wmaker
#
# Use the wm2 window manager
# wm2
#
# Use the wmx window manager
# wmx
#
# Use Motif's or LessTif's mwm
# mwm
#
# Use GNOME
# exec gnome-session
				

Note that the sample .xinitrc file in Listing 4.2 is currently set to use the K Desktop Environment. To use a different window manager (if installed on your system), add or remove the appropriate pound sign in the file; then use the startx command to start a new session:

					
   # startx
				

Share ThisShare This

Informit Network