Run Levels and Startup Scripts

By | July 20, 2009

In Linux there are 6 run levels, basically being the following:

Init Level Description
0 This level is reserved for the shutdown phase.
1 Single-user mode (equivalent to Windows “safe mode”)
2 Multi-user setup without NFS (Network Filing System)
3 Full multi-user with networking, starting all required services
4 Typically unused but could be set to be a “custom” level.
5 Level 3 plus the X windows service i.e. the Linux GUI
6 Reserved for “reboot” only.

Command example is: [root@testserver /]# init 3

The idea behind the setup is to make everything script-based.  For each run level, scripts are run to start each individual service, instead of having a few large files to edit by hand.  These scripts are located in /etc/rc.d/init.d, and most take as an option start or stop.  This is to allow the specific programs to start (on bootup) or stop (on shutdown).

This setup involves a bunch of directories under /etc/rc.d.  These are:

rc0.d Contains scripts to run when the system shuts down.  Technically, halt or shutdown brings the system to run level 0.  This directory is mostly made up of kill commands.

rc1.d through rc3.d Scripts to run when the system changes runlevels.  Runlevel 1 is usually single-user mode, runlevel 2 is for multi-user setup without NFS, and runlevel 3 is full multi-user and networking.

rc5.d Scripts to start the system in X11 mode.  This is the same as runlevel 3, with the exception that the xdm program starts, which provides a graphical login screen.

rc6.d Scripts to run when the system reboots.  These scripts are called by a reboot command.

init.d Actually contains all of the scripts.  The files in the rc?.d directories are really links to the scripts in the init.d directory

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.