matthewstorey.co.uk
In this section Access FAT32 Partitions | Commands | Enabling DMA | Links | File Locations | Other Settings | File Permissions | Run Levels | Services | Using Truetype Fonts

Run Levels

Linux has 6 different run levels (or operating modes):

  1. rc1.d - Single user mode.
  2. rc2.d - Single user mode with networking support.
  3. rc3.d - Multi user mode - boot up in text mode.
  4. rc4.d - Not defined.
  5. rc5.d - Multi user mode - boot up in X Windows.
  6. rc6.d - Shutdown.

Each mode has its own list of settings for what services to start and what services to shutdown. Not only does this list contain what is supposed to be running, but also the order each service should be started in.

The 'chkconfig' command will list all the registered services and display their status at each different run level.

Most of the time when you boots up, it will start in runlevel 3 or 5 depending on what it is set to. This setting can be found in the file "/etc/inittab". If you ever want to change what mode your server defaults to on bootup, just edit that file, but NEVER change it to runlevel 6 or you will set your computer to shutdown on bootup.

RC.D Directory Explanation

In the directory "/etc/rc.d" are all the run level folders starting from "rc1.d" to "rc6.d" and including "init.d".

It is in each of these "rc#.d" folders where the service run settings are kept. If you change directory to "/etc/rc.d/rc3.d", all the files that start with a capital S are the services that will start at this runlevel. All the files that start with a K are the services that will be killed at that runlevel.

The reason why services that are not supposed to run are still listed is because it is popular to switch a computer from one run level to another instead of just booting into the needed run level. That way you can boot into single user mode and apply a patch with exactly the same services running.

If you have a closer look at the files in the "rc#.d" folders. You'll see that they are symbolic links to the script file located in "/etc/rc.d/init.d". All the commands to start, stop, or reload a service are handled by these scripts. So when booting into a specific run level, it can find the correct script and knows whether to start it based on its name and link path.

Switching Run Levels

To switch between run levels without re-booting, use the following commands:

init <Run Level number>

Back to top