Runlevels - Debian (Ubuntu) / Fedora (CentOS)
There are six different runlevels in Linux, there could be more than six, but for compatibility reasons six are the default.
I have used RedHat and Debian based Linux, more specifically Fedora and Ubuntu and Debian itself, I have noticed that there is a difference in the runlevels on this different Linux distributions.
Well but first let's define the runlevels:
Runlevels in Linux are seven and they are:
- 0 = halt
- 1 = single user
- 2 = CLI, multi-user, no net
- 3 = CLI, multi-user, networked
- 4 = open
- 5 = GUI, multi-user, networked
- 6 = reboot
You can define more of them if you want, but whit this should be enough, a runlevel will define which software to start when you enter in that specific runlevel.
For example if you go to runlevel 0, the computer will halt, and probable turn off (If it is a modern computer).
When you enter a specific runlevel, Linux will run some scripts that are located at:
/etc/rc0.d Run level 0
/etc/rc1.d Run level 1
/etc/rc2.d Run level 2
/etc/rc3.d Run level 3
/etc/rc4.d Run level 4
/etc/rc5.d Run level 5
/etc/rc6.d Run level 6
So you can (If you know what you are doing) modify the way each runlevel works, you can add new scripts to any runlevel using update-rc.d command.
Now if you are switching from RedHat to Debian or the other way, you should know about a little difference (I do not know why) in the way the manage runlevels.
In Debian the default is 2, and it is usually a CLI multiuser mode, and 5 is the Graphical runlevel, in Redhat systems the runlevel 3 is the multiuser CLI, and the graphical is also 5 as in Debian. (Please read this, It seems that I am wrong, I will go deeper on this and update accordingly)
Debian Define its runlevels this way
0 -- System Halt
1 -- Single user
2 -- Full multi-user mode (Default)
3-5 -- Same as 2
6 -- System Reboot
And RedHat defines its runlevels this way.
0 — Halt
1 — Single-user mode
2 — Not used (user-definable)
3 — Full multi-user mode
4 — Not used (user-definable)
5 — Full multi-user mode (with an X-based login screen)
6 — Reboot
So, as you can see 2 is unused, and it is user-definable, actually anyone are user-definable.
To change from one runlevel to another, use the telinit command, read the man page for more info, and use with care.
Trackback URL for this post:
If you like this article, subscribe to our full rss
Please post your question in our forum and use comments only to leave your comments about the article, thanks.













"In Debian the default is 2,
"In Debian the default is 2, and it is usually a CLI multiuser mode, and 5 is the Graphical runlevel"
No this is not true. In Debian run levels 2-5 are all similar full graphical multiuser modes. There is no such as CLI multiuser mode in Debian.
Thanks, according to my
Thanks, according to my experience I am right, but of course I may be wrong, If any other of you can help on this?
thanks.
Guillermo Garron
Well believe me, you are not
Well believe me, you are not right. It's true that default runlevel is 2, but it is not CLI multiuser mode. It's full graphical mode. I have been using Debian almost 10 years now and it has always been like this. I'm writing this using Debian Etch. Current runlevel is 2 and I'm using Gnome desktop so I'm on X. I have not modified runlevels from default settings.
If you have not installed X then sure all runlevels 2-5 are CLI only, but if you have X installed then runlevels 2-5 are all similar graphical multiuser modes. Many other Linux distributuions do have runlevel 2 as a CLI multiuser mode, but Debian does not.
Well 10 years is far more
Well 10 years is far more that my experience on Debian, as I was since '97 a RedHat and Fedora user later, so I believe you, I have updated the info in the post, and will double check everything to be sure, thanks a lot pal for your info and help.
Please keep coming.
Guillermo Garron
2008 June Ubuntu Gutsy
2008 June Ubuntu Gutsy example:
root@d183z2g:~# last -aix | tail -25 | grep lvl;egrep -H '(telinit|default)' /etc/event.d/rc-default
runlevel (to lvl 2) Mon Jun 2 13:25 - 16:31 (03:06) 0.0.0.0
runlevel (to lvl 0) Mon Jun 2 13:20 - 13:25 (00:04) 0.0.0.0
runlevel (to lvl 2) Mon Jun 2 10:54 - 13:20 (02:26) 0.0.0.0
runlevel (to lvl 0) Mon Jun 2 10:44 - 10:54 (00:10) 0.0.0.0
runlevel (to lvl 2) Mon Jun 2 09:55 - 10:44 (00:48) 0.0.0.0
runlevel (to lvl 0) Sun Jun 1 21:30 - 09:55 (12:25) 0.0.0.0
runlevel (to lvl 2) Sun Jun 1 18:48 - 21:30 (02:41) 0.0.0.0
runlevel (to lvl 0) Sun Jun 1 16:22 - 18:48 (02:26) 0.0.0.0
/etc/event.d/rc-default:# This task guesses what the "default runlevel" should be and starts the
/etc/event.d/rc-default: telinit S
/etc/event.d/rc-default: RL="$(sed -n -e "/^id:[0-9]*:initdefault:/{s/^id://;s/:.*//;p}" /etc/inittab || true)"
/etc/event.d/rc-default: telinit $RL
/etc/event.d/rc-default: telinit 2
/etc/event.d/rc-default: telinit 2
Notes on the above: Ubuntu has replace /etc/inittab with a script so setting the default runlevel is not just a one value edit of a text file anymore.
I use graphical desktop and by inspecting the output from last I can see that this is runlevel 2 in Ubuntu (7.10 Gutsy)
Hope this helps,
Gary.
I am also a debian user so debian Etch appropriate stuff follows:
: #root@156ns1(~) ;last -aix | tail -25 | grep lvl;grep -H . /etc/debian_version ;egrep -H -A1 '(unlevel|default)' /etc/inittab
runlevel (to lvl 2) Fri Jun 13 09:25 - 14:48 (5+05:22) 0.0.0.0
runlevel (to lvl 6) Fri Jun 13 09:24 - 09:25 (00:00) 0.0.0.0
/etc/debian_version:4.0
/etc/inittab:# The default runlevel.
/etc/inittab:id:2:initdefault:
/etc/inittab-
--
/etc/inittab:# of runlevel.
/etc/inittab-#
/etc/inittab:# Runlevel 0 is halt.
/etc/inittab:# Runlevel 1 is single-user.
/etc/inittab:# Runlevels 2-5 are multi-user.
/etc/inittab:# Runlevel 6 is reboot.
/etc/inittab-
--
/etc/inittab:# /sbin/getty invocations for the runlevels.
/etc/inittab-#
--
/etc/inittab:# :::
/etc/inittab-###0:2345:respawn:/sbin/getty 38400 ttys/0
Note about the reboot runlevel - as I think with most unix or linux runlevel 6 is 'reboot the box'.
Post new comment