System Services and Runlevels


There are several ways to start and stop services. SUSE Linux uses the runlevel method that originated with Unix System V. Runlevels determine when, or if, a service runs. They also determine the order in which services are started.

Runlevels, generally speaking, identify the type of use for the computer. Table 22.1 explains the different runlevels in SUSE Linux; notice that they correspond somewhat directly to the basic choices of software installations presented to you during the initial installation of SUSE Linux.

Table 22.1. Runlevels

Runlevel

Description

0

System Halt, system shutdown.

1

Single User, or rescue, mode. Only root can log in.

2

Local Multiuser mode without remote networking.

3

Full Multiuser mode with network.

4

Not used.

5

Full Multiuser mode with network and X display manager (also fail-safe mode when booted directly from the boot prompt).

6

Reboot.


The minimum installation is roughly equivalent to Single User Mode, Runlevel 1, whereas the minimum graphical install corresponds to Runlevel 3. The gluttons who want a graphical desktop use Runlevel 5, the whole enchilada.

While the system is running, you can actually change your current runlevel. When you change runlevels, all services essential to your current runlevel are stopped and the services essential to the new runlevel are started.

To do this, enter the init command at a shell prompt, followed by the runlevel number you want to switch to. For example, if you want to switch from runlevel 5 (complete with X and a desktop environment) to runlevel 3 (the minimal graphical environment), you would complete the following:

  • Open a terminal session and switch to your root user account.

  • At the shell prompt, run the init script for runlevel 3 by entering init 3.

When you do this, init consults the /etc/inittab configuration file and runs /etc/init.d/rc with 3 (the new runlevel) as a parameter. The rc utility runs stop scripts for every service missing a start script in /etc/init.d/rc3.d, but having a stop script in /etc/init.d/rc5.d.

Stop scripts have filenames that begin with K (for "kill"), and start scripts begin with S (for "start"). The numbers following the letter indicate an order for each script to be executed. This prevents files with some dependencies from crashing before they stop.

After all the unnecessary runlevel 5 scripts have been stopped, the start scripts run for services needed in runlevel 3 but not in runlevel 5.

When you installed SUSE Linux, you were given the option to set your system's default run level. By default, this is runlevel 5. This is usually the best option for most users. However, suppose it isn't the right choice for you. Suppose you want to use your SUSE Linux system as a server (which it can do very well) and you don't want the CPU spending unneeded cycles redrawing your graphical screens. You would prefer it to boot, by default, to a text-based prompt while retaining the capability to run your graphical desktop when needed. In this situation, runlevel 3 would be a better choice.

You can set your default runlevel in two ways. First, you can edit your /etc/inittab configuration file with a text editor, as shown in Figure 22.5.

Figure 22.5. Editing the /etc/inittab file.


Notice that about three-fourths of the way down the screen, a line reads as follows:

id:5:initdefault:

This line specifies which runlevel your system should boot to by default. If you want to change this to runlevel 3, you should complete the following:

1.

Open a terminal session and switch to your root user account.

2.

At the shell prompt, enter vi /etc/inittab.

3.

Arrow down to the id:5:initdefault: line in the file.

4.

Press Ins.

5.

Change the 5 to a 3.

6.

Press Esc.

7.

Enter :exit.

8.

Reboot your system.

When the system boots, it will enter runlevel 3, as shown in Figure 22.6.

Figure 22.6. Booting into runlevel 3.


When it's finished booting, your system will display a simple, text-based screen asking you to authenticate. After logging in, you can optionally start your graphical environment by entering startx from the shell prompt.

The second way you can change your default run level is with YaST. If you're not comfortable using Linux text editing tools, you can let YaST do the work for you. To change your default runlevel using YaST, complete the following:

1.

Start YaST and navigate to the System, System Services (Runlevel) module.

2.

Select Expert Mode. The screen in Figure 22.7 is displayed.

Figure 22.7. Changing the default runlevel in YaST.


3.

In the Set Default Runlevel After Booting drop-down list, select the default runlevel for your system.

4.

Select Finish.

The next time you restart your system, it will boot to the default runlevel you configured.



SUSE Linux 10 Unleashed
SUSE Linux 10.0 Unleashed
ISBN: 0672327260
EAN: 2147483647
Year: 2003
Pages: 332

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net