11.3. Changing Runlevels

Generally, two things happen when you change runlevels. First, stop scripts of the current runlevel are launched, closing down some programs essential for the current runlevel. Then start scripts of the new runlevel are started. Here, in most cases, a number of programs are started. For example, the following occurs when changing from runlevel 3 to 5:

  1. The administrator (root) tells init to change to a different runlevel by entering init 5.

  2. init consults its configuration file (/etc/inittab) and determines it should start /etc/init.d/rc with the new runlevel as a parameter.

  3. Now rc calls all the stop scripts of the current runlevel, but only for those where there is no start script in the new runlevel. In this example, these are all the scripts that reside in /etc/init.d/rc3.d (old runlevel was 3) and start with a K. The number following K specifies the order to start, as there are some dependencies to consider.

  4. The last things to start are the start scripts of the new runlevel. These are, in this example, in /etc/init.d/rc5.d and begin with an S. The same procedure regarding the order in which they are started is applied here.

When changing into the same runlevel as the current runlevel, init only checks /etc/inittab for changes and starts the appropriate steps (e.g., for starting a getty on another interface).