Many people get confused when trying to boot into a runlevel other than runlevel 5. For example, runlevel 3, disabiling the GUI front end with which most users are most familiar. Hopefully, this howto will help answer the questions: “How do I disable X?” or “How do I boot without X?” or even “How do I get into single user mode?”
Requirements
One requirement of this document is to have an understanding of what runlevels are, how changing runlevels will impact your system, and what services may or may not be started. In general this is beyond the scope of this document but I will give a quick run down of things as listed in /etc/inittab.
Runlevels
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. As you can see you use runlevels everytime you shutdown (runlevel 0) or reboot (runlevel 6) your machine. Most users boot to runlevel 5 with X11 support and a GUI login. Some however, boot to Full multiuser mode (runlevel 3) and may choose to “startx” manually once logged in. Single user mode (runlevel 1) can be very handy if you have forgotten your root password or are having trouble booting for any number of reasons. Full multi user mode (runlevel 3) is desirable when you are having trouble with X11 and would like to repair your xorg configuration or when running a server where you do not want the added overhead of having X running.
Doing the work
We will discuss ways to change your runlevel in this howto. First how to change your runlevel “permanently.” Second how to change your current runlevel and finally how to change the runlevel at boot time.
Editing /etc/inittab to change your default runlevel
-
Open /etc/inittab in your favorite editor (I use nano).
1su -c 'nano -w /etc/inittab'<br /> -
On about line 18 you will see a line like the one shown below.
1id:5:initdefault:<br /> -
You simply change the “5” in this case to the runlevel you desire. Save the file and exit.
Changing your current run level
-
You can change runlevels using the telinit or init commands as in the example below.
1su -c 'telinit 3'<br />
Changing your runlevel at boot time.
-
Reboot then “Press any key” to enter the grub menu.
-
Choose your desired kernel and press “a” to modify the kernel arguments.
-
Simply add a 3 to the line for runlevel 3 or 1 for single user mode and Press “enter”. After pressing enter press “b” to boot with the changes you have made. (NOTE: If you are having booting issues you might want to remove “quiet” and “rhgb.”)
-
Log in and do the damage you desire. If you are booting to single user you do not need to login you will simply be presented with a prompt.
-
Logout, change runlevels or reboot as needed.
More Information
Disclaimer
We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #centos on irc.freenode.net