Sunday, December 7, 2008

How to Change Runlevels

How to Change Runlevels

by bobjensen last modified Jan 30, 2008 02:46 AM
— filed under:

Many people get confused when trying to boot in to a runlevel other than runlevel 5, for example runlevel 3, disabiling the GUI front end with which most users are 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 to 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 Fedora Core 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

  1. Open /etc/inittab in your favorite editor (I use nano).

    su -c 'nano -w /etc/inittab'
    
  2. On about line 18 you will see a line like the one shown below.

    id:5:initdefault:
    
  3. You simply change the "5" in this case to the runlevel you desire. Save the file and exit.

Changing your current run level

  1. You can change runlevels using the telinit or init commands as in the example below.

    su -c 'telinit 3'
    

Changing your runlevel at boot time.

  1. Reboot then "Press any key" to enter the grub menu.

  2. Choose your desired kernel and press "a" to modify the kernel arguments.

  3. 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.")

  4. 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.

  5. 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 #fedora on irc.freenode.net

Document Actions