Getting To Runlevel 5

On RedHat or CentOS, when the system boots up, the first program to be run is "init" which tries to switch the system into the runlevel that is set in /etc/inittab. It runs all of the startup scripts that are defined for that level and then invokes the login shell or display manager that is used for that runlevel. Once these steps are taken, your system is up and running and you should be able to login.

The two most commonly used runlevels are 3 and 5. Runlevel 3 starts up without a windowed GUI (i.e. simple terminal login) while runlevel 5 starts up a display manager, window system and some type of desktop GUI. If you look at /etc/inittab, you'll see something that looks like this:

     id:5:initdefault:

In this case, this tells init to start up in runlevel 5.

If you install a minimal system, a server or any of one or more other predefined configurations, the install program may not install the display manager, window system or desktop GUI. When you boot such a system, it will come up in runlevel 3 and the console will show a simple login prompt. After working with the CLI for a while, you may decide that you really want the GUI back. Here are the simple steps necessary to switch your system to runlevel 5 and start the display manager, window system and Gnome desktop GUI.

Login to the console and install the missing packages. There are two ways to do this:

     su
     yum -y groupinstall basic-desktop desktop-platform x11 fonts

or, you can try:

     su
     yum -y groupinstall "GNOME Desktop Environment"

At this point, you should be able to start up the desktop by typing this at the command line:

     startx

If this goes well, you can proceed to the next step which is convincing the display manager to run after init is all done starting the system. Firstly, you should check that the Gnome Display Manager is actually installed:

     su
     yum -y install gdm

Once GDM is installed, you should create the file, using your favorite text editor, that tells init which display manager to start:

/etc/sysconfig/desktop:

     DISPLAYMANAGER="GNOME"

To test whether you've got it right, you can enter the following at the command line (exit the desktop, if you still have it running as a result of running "startx"):

     su
     init 5

This should bring up the display manager, which will prompt you for a userid and password and then start the Gnome Desktop after you login. If init doesn't start the display manager properly, and you see a message like this in /var/log/messages:

     init:x respawning too fast, disabled for 5 minutes.

You've done something wrong. You should go back and check that all of the packages are installed properly, that startx works properly, and that /etc/sysconfig/desktop defines the GNOME display manager.

Once you get "init 5" to work, you can safely edit /etc/inittab to start the system in runlevel 5:

/etc/inittab:

.

       .

id:5:initdefault:

Do not alter /etc/inittab to runlevel 5 until you're sure that "init 5" works. If you do and "init 5" fails, your system won't reboot. If all is well, you can reboot the system and the familiar window manager login screen should appear automatically. If not, you're probably faced with booting a standalone OS, such as Knoppix, to repair the damage.