Monday, November 19, 2007

Change Linux RunLevels Howto

Runlevels on linux OS presents major differences on how your linux box will boot up and behave. Runlevels on linux changes a variety of execution patterns on loading up INIT process, environment, kernel modules, applications and services when booting up a linux box.

In Linux, runlevels are represented by /etc/inittab text file. The default runlevel is always specified from /etc/inittab text file.

Currently there are several runlevels that exist and being supported by linux boxes. Here are the most currently used runlevels :

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Runlevels Descriptions
0 - halt
1 - Single user mode
2 - Multiuser, without NFS (The same as 3, if you do not have networking)
3 - Full multiuser mode (terminal mode)
4 - unused
5 - X11 (X mode)
6 - reboot
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The most commonly used runlevels in a currently running linux box are 3 and 5. You can change runlevels in many ways.

A runlevel of 5 will take you to GUI enabled login prompt interface and desktop operations. Normally by default installation, this would take your to GNOME or KDE linux environment. A runlevel of 3 would boot your linux box to terminal mode (non-X) linux box and drop you to a terminal login prompt. Runlevels 0 and 6 are runlevels for halting or rebooting your linux respectively.


Here are a quick run down on how to change runlevels in several ways:


How to change the default runlevel?
-----------------------------------

To change the default runlevel in fedora ,edit /etc/inittab and find the line that looks like this:

id:5:initdefault:

The number 5 represents a runlevel with X enabled (GNOME/KDE mostly). If you want to change to runlevel 3, simply change this

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
id:5:initdefault:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

to this

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
id:3:initdefault:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Save and reboot your linux box. Your linux box would now reboot on runlevel 3, a runlevel without X or GUI. Avoid changing the default /etc/iniittab runlevel value to 0 or 6 .


How to change runlevel during bootup time?
------------------------------------------

When currently booting, press any key to take you to GRUB boot menu. Choose your desired kernel version and press 'e' to edit or modify the kernel argument. Simply append the runlevel you wish to boot up from. If you wish to boot to runlevel 3, simple append 3 from the last kernel argument separated by a space, press enter when done. Now press 'b' to continue and boot from your saved or modified kernel parameters. This would take you to the changed runlevel you have just specified.


How to change your current runlevel or on-the-fly runlevel?
-----------------------------------------------------------

If you wish to change from runlevel 5 to runlevel 3, simply issue as root

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# telinit 3
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Special runlevels can also be specified by telinit.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Runlevels Description
a,b,c process only those /etc/inittab file entries having runlevel a,b or c.
Q or q re-examine the /etc/inittab file.
S or s switch to single user mode.
U or u re-execute itself. No re-examining of /etc/inittab file happens.
7- 9 undocumented and reserved
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

If you wish to see more telinit argument, man telinit. Be careful with /etc/inittab file when changing your default runlevel.

0 comments:

Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy