X Display Server  «Prev  Next»
Lesson 6 Starting X in RedHat
Objective What is gdm and startx?

Starting X installation Graphical login

The default X installation provides a graphical login after you have installed X and rebooted. This graphical login screen is actually an X program known as gdm, or the GNOME Display Manager. In addition to prompting for username and password, gdm implements authentication using the X standard, host-based access control, and other security-conscious facilities.
The GNOME Display Manager (GDM) is still used in Red Hat Enterprise Linux (RHEL) 9.4 as the default display manager. GDM is an integral part of the GNOME desktop environment, which is also the default desktop environment for RHEL 9.4.
Key Features of GDM in RHEL 9.4:
  • Wayland Support: GDM supports Wayland sessions by default, though X11 is still available and can be used as an alternative.
  • Session Management: Allows users to select between different desktop environments or window managers at login if multiple are installed.
  • Customizations: Administrators can configure GDM through the /etc/gdm configuration files or using dconf settings.

If you are using a graphical interface in RHEL 9.4, it is likely managed by GDM unless you have replaced it with another display manager (e.g., LightDM, SDDM).
The gdm default login screen
The gdm default login screen

If you change your default run-level, gdm might not start automatically. Run-levels describe Linux boot states and include graphical, multi-user, and standalone modes of operation. The run-level a Linux system boots to is specified in /etc/inittab, and is rarely modified once set.

What does changing run-levels in Red Hat require?

An administrator might change the run-level from graphical to multi-user if there will be no monitor attached to the Linux machine. Known as a "headless" machine, Linux computers without a monitor have no need for a graphical system since the monitor consumes resources.
What is a run-level?
A run-level is a system state that is defined by the services listed in /etc/rc.d. Typically, advanced administration of a machine is done by switching run-levels (or state) to perform tasks such as minimal resource usage, run-level 3, shutdown run-level 0, or maintenance.
Maintenance is
  1. run-level or
  2. single user mode, as it is commonly known.

Unix/Linux run-level Comparison Chart

If you happen to work with AIX, Solaris, HP-UX, Ubuntu, Fedora, Free BSD and/or Red Hat Enterprise Linux, then it can get a bit confusing figuring out which run-level does what. Please refer to the Wikipedia reference at the bottom of this article to get more information on cross platform run-level comparisons.
  • System Start−up and Shutdown: During system start−up, a series of scripts are run to start the services that you need. These include scripts to start network interfaces, mount directories, and monitor your system. Most of these scripts are run from subdirectories of /etc/rc.d. The program that starts most of these services up when you boot and stops them when you shut down is the /etc/rc.d/rc script. The following sections describe run−level scripts and what you can do with them.
  • Starting run−level scripts: As previously mentioned, the /etc/rc.d/rc script is a script that is integral to the concept of run levels. Any change of run level causes the script to be executed, with the new run level as an argument. Linux runs in three different states: 1, 3, and 5 (referred to as run levels). Each run level is used to perform different functions. At Level 1 (also called single-user mode), Linux operates with a minimum of processes so that you can make configuration changes and debug problems.
  • Three Different States: Level 3 is essentially the same as Level 5 except that Level 3 does not run the X server, it is nongraphical. You typically run servers that do not need to run graphical applications, such as word processors, at Level 3. Level 5 is the default for personal workstations. You can use GRUB (Grand Unified Bootloader) to select a different Linux run level. When GRUB appears, press e for edit. Three lines appear. Press the down-arrow key to select the line that begins with kernel. Press the e key again, append either 1, 3, or 5, at the end of the line and press the Enter key. Next, press the b key and your computer boots into the specified state.

When to use startx

If you are not in the graphical run-level and you want to start the X server, then you may use the startx script. This script is simply a front-end for xinit, which actually starts the X server and any user-configured clients. The xinit program checks to make certain no X server is already running, sets up lock files and other server-related details, then executes the X server proper.
1) To start the X server, you type startx at the command prompt.
Red Hat Linux release 6.2 (Zoot)
Kernel 2.2.14-5.0 on an i586

localhost login: user
Password:
Last login: Wed Jun 21 16:17:25 on tty1
[user@localhost user]$ startx
1) To start the X server, you type startx at the command prompt.
  • Operating System: Red Hat Linux release 6.2 (Zoot)
  • Kernel Version: 2.2.14-5.0
  • Architecture: i586
  • Hostname: localhost
  • Username: user
  • Last Login: Wed Jun 21 16:17:25 on tty1
  • Command Entered: startx

2) As the X server starts, notice the information it returns about your hardware.
2) As the X server starts, notice the information it returns about your hardware. This screen shows several error messages you may use for troubleshooting.
This screen shows that neither the user's fvwm configuration file, .fvwmrc, nor the system-wide configuration files are present.
These are the missing system-wide configuration files.

3)You can now use the X Windows System.
3) You can now use the X Windows System. This screen shows the application window that appears in the lower right corner when using fvwm2 a common window manager. This is a close-up from a default X session.

Start the X Window System using `startx` in Red Hat Linux

To start the X Window System using `startx` in Red Hat Linux, follow these steps:
  1. Ensure the X Window System is Installed
    • Verify that the X Window System and a graphical desktop environment (e.g., GNOME or KDE) are installed:
      sudo dnf groupinstall "Server with GUI"
      
    • If not installed, use the above command to install it.
  2. Install the startx Command
    • The startx command is part of the xorg-x11-server-utils package. Install it if it's not already available:
      sudo dnf install xorg-x11-server-utils
      
  3. Switch to a Non-Root User
    • The startx command should not be run as the root user for security reasons. Switch to a non-root user:
      su - <username>
      
  4. Start X Using startx
    • Simply run the following command to start the X Window System:
      startx
      
  5. Verify or Configure .xinitrc (Optional)
    • The startx command reads from the ~/.xinitrc file to determine which graphical environment to start.
    • If no ~/.xinitrc file exists, create one and specify the desired desktop environment:
      echo "exec gnome-session" > ~/.xinitrc
              
      Replace gnome-session with the appropriate command for your desktop environment, such as startkde for KDE.
  6. Troubleshooting
    • Graphics Issues: Ensure that the appropriate drivers for your GPU are installed.
    • Error Messages: Check the X server logs in /var/log/Xorg.0.log for detailed information if startx fails.

Do not call xinit directly. The startx script performs setup activities that, if not performed, would make using your X session practically useless for productive purposes. X will not be initiated with the proper options. startx takes care of all of this.
Sometimes you might want to pass options directly to the X server to change its behavior from the default. The startx script sends all its command line arguments after a -- to the X server.
For example,
startx -- -bpp 8
will instruct the X server to use 8-bit color instead of its configured default.
The next lesson discusses configuring the X server startup with .xinitrc.

SEMrush Software 6 SEMrush Banner 6