Understanding the Concept of Runlevels

When starting a server, you probably need the server to be fully functional. Sometimes, however, for troubleshooting a server, you need to start with only a few services loaded, instead of loading all services. Linux meets this need with runlevels. By default, seven runlevels determine exactly what is happening when your server boots one of them. Listing 10-4 shows how these runlevels are defined in /etc/inittab.

Listing 10-4. Defining Runlevels in inittab

# runlevel 0 is System halt (Do not use this for initdefault!)

# runlevel 1 is Single user mode

# runlevel 2 is Local multiuser without remote network (e.g. NFS)

# runlevel 3 is Full multiuser with network

# runlevel 4 is Not used

# runlevel 5 is Full multiuser with network and xdm

# runlevel 6 is System reboot (Do not use this for initdefault!)

As you can see, you can actually use four runlevels when booting the system. Runlevel 4 is not in use, runlevel 0 is for system halt, and runlevel 6 is for system reboot, so they are not used to determine what should happen when booting. Of these runlevels, runlevel 1 is the basic runlevel. In this runlevel, only a few services start, which ensures that a user can log in to single-user mode. This mode offers only a few more items than the items that are activated in the initial boot phase and is therefore perfect for troubleshooting. Runlevel 1 doesn't provide a normal login prompt but activates the sulogin program. This program prompts for the password of user root after starting the runlevel. You should be aware of the following characteristics when working in single-user mode:

• There are no virtual consoles, except for the first tty1.

• Just one user can be logged in at the same time.

• No graphical user environment can be used.

Some more services are offered when booting in runlevel 2. This runlevel adds the option to work with multiple users and some basic networking to the items started in runlevel 1. You should, however, be aware that no network services are started in runlevel 2; just the scripts to use your server as a client to other network services are started. Because no network services are started in runlevel 2, this is not a runlevel you would like to use as an operational runlevel but rather for troubleshooting connectivity on the network. Runlevel 2 can be summarized as follows:

• Multiple users can log in.

• The system can be used as a network client.

• No network services are started.

• No graphical user environment is started automatically.

Runlevel 3 is often the default runlevel for servers, because it provides everything you need except for the graphical user environment. The most important characteristics of runlevel 3 are as follows:

• It offers a complete operational server.

• Graphical environment can be started manually.

After a default installation, your server will start runlevel 5. In this runlevel, you'll have it all— a complete graphical environment as well as all network services. Although this is a complete runlevel offering everything you need, on servers it doesn't make sense to make it your default runlevel because it loads the graphical environment by default. This graphical environment uses a lot of resources and often is not needed, especially when your server is installed in a server room without a monitor connected to it. If you want to run graphical programs on your server remotely, you don't need to run a complete graphical environment on the server. See Chapter 18 for more information.

Was this article helpful?

0 0

Post a comment