Setting up a Graphical Login
Setting up a Graphical Login
Setting up your Linux workstation to display a graphical login screen is easy-all you have to do is make the appropriate selection during the installation. Even if you have not initially elected to have a graphical login screen, you can easily set it up once you know the details. The following sections explain how your CentOS Linux system displays the graphical login screen.
Understanding How init Starts the Display Manager
A process named init starts the initial set of processes on your CentOS Linux system. What init
starts depends on the current run level, the contents of the /etc/inittab
file, and the shell scripts located in the /etc/rc.d
directory and its subdirectories. For now, you don't need to understand the details; you must know, however, that the graphical login screen starts at run level 5.
Cross Ref |
Chapter 20 describes in detail the init process, the |
The last line of the /etc/inittab
file is responsible for starting the graphical login process with the following entry (the number 5 denotes run level 5):
x:5:respawn:/etc/X11/prefdm -nodaemon
This command runs /etc/X11/prefdm
, a shell script that contains the following lines:
#!/bin/sh PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin # Shut down any graphical boot that might exist. if [ -x /usr/bin/rhgb-client ]; then /usr/bin/rhgb-client -quit fi # We need to source this so that the login screens are translated. [ -f /etc/profile.d/lang.sh ] && . /etc/profile.d/lang.sh # Run preferred X display manager # Try autologin first, if wanted... if [ -f /etc/sysconfig/autologin -a -x /usr/sbin/autologin ]; then if /usr/sbin/autologin; then exit 0 fi # If autologin fails (bad permissions, etc.), we get here - # time to start a real display manager. fi preferred= if [ -f /etc/sysconfig/desktop ]; then . /etc/sysconfig/desktop if [ "$DISPLAYMANAGER" = GNOME ]; then preferred=gdm elif [ "$DISPLAYMANAGER" = KDE ]; then preferred=kdm elif [ "$DISPLAYMANAGER" = XDM ]; then preferred=xdm fi fi if [ -z "$preferred" ]; then if which gdm >/dev/null 2>&1; then preferred=gdm elif which kdm >/dev/null 2>&1; then preferred=kdm elif which xdm >/dev/null 2>&1; then preferred=xdm fi fi if [ -n "$preferred" ] && which $preferred >/dev/null 2>&1; then exec `which $preferred` $* >/dev/null 2>&1 fi if which gdm >/dev/null 2>&1; then exec `which gdm` $* >/dev/null 2>&1 elif which kdm >/dev/null 2>&1; then exec `which kdm` $* >/dev/null 2>&1 elif which xdm >/dev/null 2>&1; then exec `which xdm` $* >/dev/null 2>&1 fi # Catch all exit error exit 1
This script starts a specific display manager-gdm, kdm, or xdm-depending on the setting of the DISPLAYMANAGER
variable in the /etc/sysconfig/desktop
file. The display manager is a program responsible for displaying the graphical login window, authenticating users who log in, running initialization scripts at the start of a session, and cleaning up after the session. The display manager process manages the display, making it available to the users and cleaning up after the user finishes a session. Note that of the three display managers-gdm, kdm, or xdm-xdm is the most generic.
If you have not enabled the graphical login screen during Red Hat installation, you can do so by editing the /etc/inittab
file. Locate the line containing initdefault
, and make sure that it reads as follows:
id:5:initdefault:
Caution |
Before you edit the |
After editing the default run level in /etc/inittab
, you can either reboot the system or type the following command to switch to run level 5:
telinit 5
Learning the GNOME Display Manager (gdm)
The gdm program is a display manager similar to xdm, the X display manager. Like xdm, gdm starts an X server for each local display, displays a login dialog box, and enables the user to log in to the system. Figure 9-1 shows a typical graphical login screen displayed by gdm.
When gdm runs, it reads various configuration parameters from the configuration file /etc/X11/gdm/gdm.conf
, which has a structure similar to a Windows INI
file. For example, here is a typical gdm.conf
file:
[daemon] AlwaysRestartServer=false AutomaticLogin= AutomaticLoginEnable=false Chooser=/usr/bin/gdmchooser Configurator=/usr/sbin/gdmsetup --disable-sound --disable-crash-dialog DefaultPath=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin DisplayInitDir=/etc/X11/gdm/Init FailsafeXServer= FirstVT=7 FlexibleXServers=5 GnomeDefaultSession=/usr/share/gnome/default.session Greeter=/usr/bin/gdmgreeter Group=gdm HaltCommand=/usr/bin/poweroff;/sbin/poweroff;/sbin/shutdown -h now;/usr/sbin/shutdown -h now KillInitClients=true LocalNoPasswordUsers= LogDir=/var/log/gdm PidFile=/var/run/gdm.pid PostSessionScriptDir=/etc/X11/gdm/PostSession/ PreSessionScriptDir=/etc/X11/gdm/PreSession/ RebootCommand=/sbin/shutdown -r now;/usr/sbin/shutdown -r now RemoteGreeter=/usr/bin/gdmlogin RootPath=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin ServAuthDir=/var/gdm SessionDir=/etc/X11/gdm/Sessions/ StandardXServer=/usr/X11R6/bin/X SuspendCommand= TimedLogin= TimedLoginDelay=30 TimedLoginEnable=false User=gdm UserAuthDir= UserAuthFBDir=/tmp UserAuthFile=.Xauthority VTAllocation=true XKeepsCrashing=/etc/X11/gdm/XKeepsCrashing Xnest=/usr/X11R6/bin/Xnest -name Xnest [security] AllowRemoteAutoLogin=false AllowRemoteRoot=true AllowRoot=true RelaxPermissions=0 RetryDelay=1 SessionMaxFile=524388 UserMaxFile=65536 [xdmcp] DisplaysPerHost=1 Enable=false HonorIndirect=true MaxPending=4 MaxPendingIndirect=4 MaxSessions=16 MaxWait=15 MaxWaitIndirect=15 Port=177 Willing=/etc/X11/gdm/Xwilling [gui] GtkRC=/usr/share/themes/Bluecurve/gtk-2.0/gtkrc MaxIconHeight=128 MaxIconWidth=128 [greeter] BackgroundColor=#27408b BackgroundImage= BackgroundProgram= BackgroundRemoteOnlyColor=true BackgroundScaleToFit=true BackgroundType=0 Browser=false ConfigAvailable=false DefaultFace=/usr/share/pixmaps/nobody.png Exclude= bin,daemon,adm,lp,sync,shutdown,halt,mail,news,uucp,operator,nobody,gdm,postgres,pvm,rpm GlobalFaceDir=/usr/share/faces/ GraphicalTheme=Bluecurve GraphicalThemeDir=/usr/share/gdm/themes/ Icon=/usr/share/pixmaps/gdm.png LocaleFile=/etc/X11/gdm/locale.alias LockPosition=true Logo= MinimalUID=500 PositionX=0 PositionY=0 Quiver=true RunBackgroundProgramAlways=false SetPosition=false ShowGnomeChooserSession=false ShowGnomeFailsafeSession=false ShowXtermFailsafeSession=false SystemMenu=true TitleBar=false Use24Clock=false UseCirclesInEntry=false Welcome=Welcome to %n XineramaScreen=0 [chooser] Broadcast=true DefaultHostImg=/usr/share/pixmaps/nohost.png HostImageDir=/usr/share/hosts/ Hosts= ScanTime=3 [debug] Enable=false [servers] 0=Standard [server-Standard] command=/usr/X11R6/bin/X flexible=true name=Standard server
The [servers]
section of the file specifies the displays on which gdm displays the login dialog box. Each line of this section starts with a display number and shows the command needed to start the X server.
You see the term greeter
used often in the display manager configuration file. Greeter refers to the login screen-the user interface through which the display manager prompts the user to log in to the system.
The different sections in the configuration file control different aspects of the graphical login screen as well as the tasks the user can perform from that screen. Table 9-1 describes the gdm configuration options, organized by sections.
Configuration Option |
Description |
---|---|
[daemon] section | |
|
If set to true, gdm always kills the existing X server and starts a new one. |
|
If set to true, automatically log in the user specified in the |
|
If a user name is specified and |
|
Full path and name of the |
|
Full path and name of the |
|
Path (names of directories separated by colons) to be used for the user's session |
|
Directory containing the initialization scripts (the default is |
|
Full path name of script that gdm should run to provide a failsafe GUI login screen |
|
The virtual terminal (VT) number where X should be run (default is 7) |
|
Maximum number of X servers to run |
|
Full path name of file that gdm should read if there are no user GNOME session files (the default is |
|
Full path and name of the greeter executable file, followed by arguments (typically, this should be |
|
Group name under which |
|
Full path and arguments to the commands to be executed when the user selects Halt from the System menu (typically, this should be |
|
When set to true, gdm kills the X clients started by the |
|
Comma-separated list of users that are allowed to log in without password |
|
Directory containing the log files for the displays (the default is |
|
Name of the file where the process ID (pid) of the gdm process is stored (the default is |
|
Directory that contains the PostSession scripts-scripts run after the user logs out (the default is |
|
Directory that contains the |
|
Full path and arguments to the command to be executed when the user selects Reboot from the System menu (typically, this should be |
|
Full path name of the greeter executable file for remote displays |
|
Path (names of directories separated by colons) to be used for the |
|
Directory (the default is |
|
Directory containing scripts for all session types available on the system (the default is |
|
Path name of standard X server (the default is |
|
If a user name is specified and |
|
The number of seconds delay before the user specified in |
|
If set to true, automatically logs in the user specified in the |
|
User name under which |
|
Directory where the user's |
|
Directory where a fallback cookie (which simply refers to the small amount of authentication information) is created if gdm fails to update the user's |
|
Name of the file for storing the user's authentication cookies (the default is |
|
If true, automatically allocate virtual terminal (VT) for use by X server (default is |
|
Full path name of a script that gdm should run if X keeps crashing (the default script is |
|
Full path name of the nested X server ( |
[security] section | |
|
When set to true, allows remote timed login (the default is |
|
When set to true, the root user can log in remotely (the default is |
|
When set to true, the root user can log in at the console (the default is |
|
0 = |
|
Number of seconds to wait before gdm displays the login window again after a failed login (the default is 3 seconds) |
|
Maximum size (in bytes) of files that gdm will read or write (the default is 64KB, or 65,536 bytes) |
[xdmcp] section | |
|
Number of displays per host (the default is |
|
When set to true, |
|
When set to true, gdm allows remote execution of the |
|
Maximum number of pending connections (the default is |
|
Maximum number of |
|
Maximum number of remote display connections that gdm will accept (the default is |
|
Maximum number of seconds that gdm waits for a response from a display before assuming that the display is not active anymore (the default is 15 seconds) |
|
Maximum number of seconds that gdm waits for a remote display to complete protocol negotiations after the display requests a chooser (the default is 15 seconds) |
|
The UDP port number where gdm listens for XDMCP requests (the default is |
|
Full path name of script to run to generate replies to XDMCP BroadcastQuery requests (the default is |
[gui] section | |
|
Path name of file that contains the theme to be used by the |
|
Maximum width (the default is 128 pixels) of icons that the face browser will display (gdmlogin can display a face browser containing icons for all the users on a system; these icons can be installed globally by the system administrator or in the users' home directories) |
|
Maximum height (the default is 128 pixels) of icons that the face browser will display |
[greeter] section | |
|
Background color |
|
Pathname of image to use as background (when |
|
Pathname of program to run to draw the background |
|
When set to |
|
When set to |
|
Type of background for the greeter, |
|
When set to |
|
When set to |
|
A file, readable by the |
|
Comma-separated list of user names to be excluded from the face browser; the excluded users will still be able to log in |
|
Directory where face files (each containing an icon showing a user's face) are located (the default is |
|
Name of graphical theme to use (default is |
|
Directory where graphical theme files are located (the default is |
|
A file, readable by the |
|
Full pathname for the file in GNU locale format, with entries for all languages supported on the system (the default is |
|
When set to |
|
A file, readable by the |
|
Users with this user ID or higher can log in (the default is 500) |
|
Horizontal and vertical position of greeter window |
|
When set to |
|
When set to |
|
When set to |
|
When set to |
|
When set to |
|
When set to |
|
When set to |
|
When set to true, show a title bar on the greeter window (the default is |
|
When set to |
|
When set to |
|
The English welcome message that the |
|
The Xinerama screen where greeter is displayed (default is |
[chooser] section | |
|
When set to |
|
File containing an image to be displayed for those hosts that do not have a unique icon file (the default is |
|
Directory (the default is |
|
Comma-separated names of hosts to list |
|
Number of seconds the chooser should wait for replies to its XDMCP broadcast query (the default is 3 seconds) |
[debug] section | |
|
When set to true, gdm saves information that can help isolate any bugs in gdm (the default is |
[servers] section | |
|
Name of the X server to start on local display number N (if your system has a single monitor, N is 0). Default is Standard |
[server-Standard] section | |
|
Full pathname of the Standard X server (the default is |
|
When set to |
|
A descriptive name of the Standard server (default is Standard server) |
Switching from GNOME to KDE
GNOME and KDE are both capable GUI environments. CentOS Linux comes with both of these GUIs, but you get GNOME as the default GUI. However, Red Hat also includes the utility script /usr/bin/switchdesk
, which enables you easily to switch from one GUI to another, and vice versa. To switch from GNOME to KDE, follow these steps:
-
From your GNOME desktop, select Main Menu>System Settings>More System Settings>Desktop Switching Tool, or type switchdesk in a terminal window. The Desktop Switcher dialog box appears.
-
In the Desktop Switcher dialog box, click the KDE radio button to select it (see Figure 9-2), then click the OK button.
Figure 9-2: Switching to KDE by Using the Desktop Switching Tool. -
A message informs you that the desktop configuration has been changed, but you must restart X for the change to take effect. Click the OK button to dismiss the dialog box.
Although the message in Step 3 states that you must restart X, all you need to do is log out of the session and log back in. To log out, select Main Menu>Log Out. When you log in again, you should get the KDE GUI.
The switchdesk
utility changes the GUI by creating the appropriate scripts in your home directory. It leaves the display manager unchanged. This means that you use the GNOME display manager, gdm, for login, even when you switch to the KDE GUI. After you log in, gdm executes a session script that eventually executes the .Xclients
script in your home directory, if that script exists.
When you run the switchdesk utility, you execute a shell script in the /usr/bin/ switchdesk
file that contains the following lines:
#!/bin/sh echo "CentOS Linux `basename $0` 3.9" echo "Copyright (C) 1999-2001 Red Hat, Inc" echo "Redistributable under the terms of the GNU General Public License" kicker=`/sbin/pidof "kdeinit: kicker"` [ -z "$kicker" ] && kicker=`/sbin/pidof kicker` [ -z "$kicker" ] && kicker=`/sbin/pidof kpanel` [ -z "$kicker" ] && kicker=`/sbin/pidof kpanel1` good=1 if [ "$DISPLAY" != "" -a "$1" = "" ]; then if [ -n "$kicker" -a -x /usr/bin/switchdesk-kde ]; then exec switchdesk-kde elif [ -x /usr/bin/switchdesk-gnome ]; then exec switchdesk-gnome elif [ -x /usr/bin/switchdesk-kde ]; then exec switchdesk-kde else echo "Desktop Switcher GUI unavailable." echo "Please install the switchdesk-kde or switchdesk-gnome packages or use" echo "switchdesk desktopname." good=0; fi else good=0; fi if [ "$good" = "0" ]; then exec switchdesk-helper $1 fi
To switch from KDE to GNOME, log in as root
, open a terminal window, and type switchdesk at the shell prompt, then select GNOME as the desktop. After you log out of KDE and log back in, you should get GNOME as your desktop.
Note that if you want to use GNOME for one session only (as opposed to making it your default GUI), simply click Session at the bottom of the login screen, and then select Gnome from the login window menu in the initial login screen, as shown in Figure 9-3.
You should get the GNOME desktop for this session. The next time you log in, the system reverts to KDE.
Learning the KDE Display Manager (kdm)
If you install only the KDE desktop or set the DISPLAYMANAGER
variable in the /etc/ sysconfig/desktop
file to KDE
, the kdm program starts the X server for the local display and displays the graphical login window through which you log in to the system. Figure 9-4 shows the graphical login screen that you see when you run the kdm display manager.
When kdm runs, it reads various configuration parameters from the configuration file /usr/share/config/kdm/kdmrc
, which has a structure similar to a Windows INI
file. For example, here is a typical kdmrc
file:
# KDM configuration example. [General] Xservers=/usr/share/config/kdm/Xservers PidFile=/var/run/kdm.pid [Xdmcp] Enable=false Xaccess=/usr/share/config/kdm/Xaccess Willing=/usr/share/config/kdm/Xwilling [Shutdown] HaltCmd=/sbin/poweroff [X-*-Core] # Core config for all displays Setup=/usr/share/config/kdm/Xsetup Startup=/usr/share/config/kdm/Xstartup Reset=/usr/share/config/kdm/Xreset Session=/usr/share/config/kdm/Xsession AutoReLogin=false AllowRootLogin=true AllowNullPasswd=true AllowShutdown=Root [X-*-Greeter] # Greeter config for all displays SessionTypes=default,kde,failsafe,gnome GUIStyle=Bluecurve LogoArea=Clock GreetFont=Sans,12,-1,5,75,0,0,0,0,0 StdFont=Sans,10,-1,5,50,0,0,0,0,0 FailFont=Sans,10,-1,5,75,0,0,0,0,0 AntiAliasing=true ShowUsers=None MinShowUID=500 SortUsers=true PreselectUser=None FocusPasswd=false EchoMode=OneStar [X-:*-Core] # Core configurations for local displays # place local display core configurations here [X-:*-Greeter] # Greeter configurations for local displays # place local display greeter configurations here
As you can see, the file is organized into sections, with each section identified by labels within square brackets. Each section specifies a related set of options that affects some aspect of the GUI login process.
Table 9-2 summarizes some common kdm
configuration options, organized by sections. I show the X display options for all displays. To customize these for a specific display, you can add a section with a name that reflects the X display to which the options apply.
Configuration Option |
Description |
---|---|
[General] section | |
|
If set to true, kdm locks the |
|
File where kdm should store its process ID (ID) |
|
File containing list of X servers to start (one per display) |
[Xdmcp] section | |
|
Number of seconds to wait for display to respond after the user has selected a host from the chooser (default is 15 seconds) |
|
If set to |
|
The UDP port number where kdm listens for XDMCP requests (default is |
|
If set to true, strips domain name from remote display names if it is equal to the local domain (default is |
|
Use the numeric IP address of the incoming connection instead of the hostname (useful on multihomed hosts, the default is |
|
Program to run to generate replies to XDMCP BroadcastQuery requests (the Xwilling program is a shell script that displays the number of users and current load average) |
[Shutdown] section | |
|
Full pathname of command to run to halt the system |
|
Full pathname of command to run to reboot the system (default is / |
[X-*-Core] section (core configuration for all displays) | |
|
If set to |
|
If set to true, kdm allows logins by |
|
Specifies who can abort all currently running programs when shutting down system; choices are |
|
Specifies who can shut down the system; possible values are |
|
If set to true, kdm will automatically restart a session after the X server crashes or if it is killed by pressing Ctrl-Alt-Backspace (default is |
|
The default mode for shutdown; choices are to shut down immediately, |
|
Number of seconds to wait before retrying to open the display after any error (default is 15 seconds) |
|
How many seconds to wait before trying to open display again (default is 5 seconds) |
|
Number of seconds to wait before timing out on the attempt to open the display (default is 120 seconds) |
|
How many minutes between successive pinging of remote displays (ping checks if network connection is up and running; default interval is 5 minutes) |
|
Program to run after a user session ends |
|
The signal to send to reset the local X server (default is |
|
Program that accepts the |
|
Filename (in user's home directory) where the last session type is stored (default is |
|
Program to run before showing the greeter window |
|
The maximum number of times to try opening a display before the display is disabled (default is |
|
How many seconds to wait before resetting the |
|
Program to run before starting a user session |
|
If set to true, restart the local X server instead of resetting after session ends (default is false) |
|
The signal to send to terminate the local X server (default is 15, which stands for SIGTERM) |
[X-*-Greeter] section (greeter configuration for all displays) | |
|
If set to true, fonts shown in the greeter should be antialiased (default is |
|
User preselected for login if |
|
What to show as user types the password; choices are |
|
Font used for the "Login Failed" message |
|
If set to true, the password input line is automatically selected to receive the keyboard input (default is |
|
If set to |
|
Horizontal position, in pixels, of greeter window |
|
Vertical position, in pixels, of greeter window |
|
The font to use for the welcome text |
|
Welcome text in greeter window (default is |
|
The look and feel of the greeter (other choices are |
|
List of user names not to be listed in the greeter when |
|
Language to use in the greeter (default is |
|
What to show in the area to the right of the text input line (other options are |
|
The image to show when |
|
Users with UID less than the specified number are not shown |
|
What to do with the Num Lock key during the time when the greeter is running; choices are |
|
User name to be preselected for login; choices are |
|
List of users to show when |
|
Names of session types that the user can select from the GUI login window |
|
Which user names, along with pictures, to show in the greeter; choices are |
|
If set to |
|
Normal font used in the greeter |