Thursday, January 15, 2009

Switching Run Levels in CentOS

I am assuming that anyone reading this is at least familar with run levels and linux but please have an understanding of what they are and how they will affect your system(s).


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 or Admin

5 - X11

6 - reboot (Do NOT set initdefault to this)

The most commonly used runlevels in CentOS are 0, 1, 3, 5 and 6. Most systems will boot into runlevel 5 with a GUI login and either Gnome or KDE as a window manager running on top of X. This is exactly what someone using the computer as a desktop will want, but for a server you will want to boot to into runlevel 3 (Full multiuser mode). From there you may choose to "startx" manually once logged in. (A common setup for me. I like the ability to have a GUI, but I don't want it running all of the time. Runlevel1 (Single user mode) has been very handy, for instance if you have forgotten your root password or are having trouble booting for any number of reasons.

To change the runlevel of the server upon boot up edit the /etc/inittab

sudo vi /etc/inittab

Around line 18 you will see a line as shown below.


You simply change the "5" in this case to the runlevel you desire. (In my case 3) Save the file and exit.

1 comment:

Steve.Lippert said...

This blog post was true for CentOS 5, and most of it still is, but the line you're looking for is now line 26.