Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It used to be that when you booted most linuxes, you would boot into runlevel 6, unless you did something during the bootloading to change the runlevel,.

The process would then look in /etc/init/rcX.d (IIRC) where X was the runlevel, and execute all the scripts begining with S in dictionary sorted order (so S01xxx ran before S20yyy).

When you went through the shutdown procedure the scripts beginning with K would be run and IIRC in reverse dictionary sort order.

Now things have changed the rcX.d directories have been moved to /etc and an /etc/rcS.d has been added, and the default runlevel is 2.

Unfortunately until now I haven't been following the changes. Can someone please describe the boot and shutdown process for runlevel 2 in present systems?

share|improve this question
Ummm ... you never booted into runlevel six. Some distros boot to 5, some to 3, debian and its deviants, errrh, derivatives, boot into 2, with 2 through 5 being equivalent. – tink May 28 '13 at 0:02
Switching to runlevel 6 is a reboot, init 6 is like shutdown -r now. – thecarpy Jan 30 '15 at 11:55

When the system transitions from one runlevel to another, it executes all the "K" scripts in the existing runlevel, in order, then all the "S" scripts in the new runlevel, in order. Debian implements parallel boot, so most of the scripts will run concurrently (but effectively in order), and there's a standard for including dependency information on each script, and tools for inserting/removing scripts. You can turn concurrency off by adding CONCURRENCY=NONE to /etc/default/rcS.

On Debian's current inittab, the command set to run at each runlevel transition is /etc/init.d/rc

When you boot, the system is considered in runlevel S. The "S" scripts in /etc/rcS.d are executed, in order (by /etc/init.d/rc).

When they complete, the system is moved into the runlevel you specified on the kernel command line, or the default runlevel, which is 2 if you don't have X installed.

There are no "K" scripts in /etc/rcS.d so nothing happens there - runlevel "S" is meant for general system initialization. But then all the "S" scripts in /etc/rc2.d are executed, in order.

Once those complete, you are officially in runlevel 2. The /etc/init.d/rc command returns, and init spaws the getty's it's configured to do, and waits for a signal to change runlevel.

When you shutdown, a signal is sent to init. Then, the system is moving from runlevel 2 to 6 (reboot) or 0 (shutdown). So all the "K" scripts in /etc/rc2.d are executed, in order. Then, all the "S" scripts in either /etc/rc6.d or /etc/rc0.d are executed, in order, if they exist.

Then since, this is runlevel 0 or 6 (ook at /etc/init.d/rc - that script explicitly tests for 0 or 6), it will immediately transition out of the runlevel, causing all the "K" scripts to run.

The final "K" script for 0 or 6 will be a command that halts/powers off or reboots the system.

share|improve this answer


Right out of my /etc/inittab (Fedora system):

# Default runlevel. The runlevels used are:
#   0 - halt (Do NOT set initdefault to this)
#   1 - Single user mode
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking)
#   3 - Full multiuser mode
#   4 - unused
#   5 - X11
#   6 - reboot (Do NOT set initdefault to this)

This line in my /etc/inittab controls my default runlevel:


Change it like so:

$ sudo vim /etc/inittab


Your current runlevel is this:

$ runlevel
N 5

So my previous runlevel is unknown (N) and my current one is 5. Temporaily change your runlevel:

telinit 3

Take a look at this article titled: Boot-Up Manager (docs), which explains how this directory is organized under Debian.

Under Debian it shows the following runlevels:

N System bootup (NONE).
S Single user mode (not to be switched to directly)
0 halt
1 single user mode
2 - 5 multi user mode
6 reboot
share|improve this answer
For extra hilarity, Linux chose runlevel 5 for multi-user X-Windows. Under Solaris, runlevel 6 is reboot just like Linux, but runlevel 5 is shutdown. I can only imagine how many Linux folks new to Solaris have had fun with that. – kurtm Oct 13 '13 at 16:32
note for future visitors: this is an old Fedora, newer releases have systemd – strugee Dec 28 '13 at 11:53
And now that's the case in Debian as well. Time to switch "default target" for "runlevel" in your mind. – mattdm May 1 '15 at 15:33

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.