Run Levels and inittab – RHEL

Now that we have already seen the boot sequence and GRUB file for linux, lets now check what is run level and one of the important file /etc/inittab which is used during booting linux.

Run Level

Operating system like linux has several services that are running. Each service will provide some functionality to OS. Example ftp service will allow other machine to FTP from your machine. Similarly network service will allow networking functionality.

But keeping all the services running while working on only few serivce will impact performance. Some times administrator does not need all the services and just need few services for working.

For this kind of situation, linux provides different runlevel. Each run level has some specific set of services running. Example if you start your linux in run level 1, some specific set of services will get started but not all. If you boot linux in run level 2 some more services will get started over and above services from run level 1. So run level is just a way to tell OS what are all services it should start during boot time.

Linux has 7 run levels, they are given as below. These run levels are defined in a file /etc/inittab which is the file read during boot time to get the default run level set and linux will boot in that run level.

0 -> Used for shutdown. Setting this in /etc/inittab, linux wont be able to boot.
1 -> Single user mode. Linux will start in single user mode. Usually used for maintenance task.
2 -> Multiuser, without NFS.
3 -> Full multiuser mode, no X Server started so no graphical display.
4 -> unused
5 -> Starts XDisplay as well. X Server is started with all graphical display.
6 -> reboot. Do not set this value in /etc/inittab, else linux will reboot continuously.

You can check the current run level of your Linux using following command.

[chramana@ap6023fems chramana]$ /sbin/runlevel
N 3

Here it gives 2 characters which are <previous Run level> <Current Run Level>. So the current run level is 3 and previous run level is null, meaning that system started with run level 3 from the very beginning.

After having this brief idea about run level we will see the content of /etc/inittab file


This file is one of the most important file for booting. Every the entry in this file has following format each seperated by “:””

Identification tag of that line : Run level numbers : Keyword : Path of script to be executed



In the above line there is no “Run level number” after 1st “:”, that means that this command will run for all the run levels.

Following are the different entries in the file

The first entry in file is


This line decide what should be runlevel at the time of booting. Here the run level is 3, that means that system will start in run level 3 by default. If we change this run level from 3 to 5 and reboot then system will start in run level 5.


This line is for system initialization and is executed at all run level. It calls the script /etc/rc.d/rc.sysinit to initialize the system during startup.

l0:0:wait:/etc/rc.d/rc 0
l1:1:wait:/etc/rc.d/rc 1
l2:2:wait:/etc/rc.d/rc 2
l3:3:wait:/etc/rc.d/rc 3
l4:4:wait:/etc/rc.d/rc 4
l5:5:wait:/etc/rc.d/rc 5
l6:6:wait:/etc/rc.d/rc 6

These lines will carry out the task based on the run level in which we are starting the system. Depending on the run level proccessing will change.
Each of this entry will call same script /etc/rc.d/rc but will pass the arguement as run level #, depending on which run level system is booting.

ca::ctrlaltdel:/sbin/shutdown -t3 -r now

This command is used to trap the key pressed and will be executed for all run level. If a combination of ctrl+Alt+Del key is pressed then it will shutdown the system by running /sbin/shutdown command. -t3 -r now are the arguements to this script.

pf::powerfail:/sbin/shutdown -f -h +2 “Power Failure; System Shutting Down”

The above line tells what needs to be done is a power falure is detected by the system. There are device drivers which will detect change in the UPS status when power goes off. When such condition occurs then this command will guide system for required action.
In this case its doing to display message “Power Failure; System Shutting Down” and system will do a clean shutdown using /sbin/shutdown script in 2 mins (hence +2 in script). This command will run for all run sequence.

ppr:12345:powerokwait:/sbin/shutdown -c “Power Restored; Shutdown Cancelled”

This is a power restore action. Suppose when power goes off and we have configured to run shutdown command after 10 mins (+10 option) and lets say power comes back in 9 mins, then we dont want to shutdown the system as power came back, in this case we can specify the action to be taken in this command.

x:5:respawn:/etc/X11/prefdm -nodaemon

The above command starts a X11 server in run level 5.

/etc/inittab calls several other script which initializes and configures the system at the time of starting.

We can also check which all services starts at what level using chkconfig command as shown below.

[root@ap6023fems chramana]# /sbin/chkconfig –list
xinetd          0:off   1:off   2:off   3:off   4:on    5:on    6:off
gpm             0:off   1:off   2:on    3:off   4:on    5:on    6:off
ypxfrd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
dc_client       0:off   1:off   2:off   3:off   4:off   5:off   6:off
lm_sensors      0:off   1:off   2:on    3:off   4:on    5:on    6:off
ldap            0:off   1:off   2:off   3:off   4:off   5:off   6:off
winbind         0:off   1:off   2:off   3:off   4:off   5:off   6:off
rpcidmapd       0:off   1:off   2:off   3:off   4:on    5:on    6:off
snmptrapd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
ripd            0:off   1:off   2:off   3:off   4:off   5:off   6:off
ocfs2           0:off   1:off   2:on    3:off   4:on    5:on    6:off
sysstat         0:off   1:on    2:on    3:off   4:on    5:on    6:off
squid           0:off   1:off   2:off   3:off   4:off   5:off   6:off
messagebus      0:off   1:off   2:off   3:off   4:on    5:on    6:off
rawdevices      0:off   1:off   2:off   3:off   4:on    5:on    6:off
FreeWnn         0:off   1:off   2:off   3:off   4:off   5:off   6:off
lisa            0:off   1:off   2:off   3:off   4:off   5:off   6:off
crond           0:off   1:off   2:on    3:off   4:on    5:on    6:off
openibd         0:off   1:off   2:on    3:off   4:on    5:on    6:off
cups            0:off   1:off   2:on    3:off   4:on    5:on    6:off
ripngd          0:off   1:off   2:off   3:off   4:off   5:off   6:off
iiim            0:off   1:off   2:on    3:off   4:on    5:on    6:off
cpuspeed        0:off   1:on    2:on    3:off   4:on    5:on    6:off
multipathd      0:off   1:off   2:off   3:off   4:off   5:off   6:off
apmd            0:off   1:off   2:on    3:off   4:on    5:on    6:off
rdisc           0:off   1:off   2:off   3:off   4:off   5:off   6:off
httpd           0:off   1:off   2:off   3:off   4:off   5:off   6:off
yppasswdd       0:off   1:off   2:off   3:off   4:off   5:off   6:off
rpcgssd         0:off   1:off   2:off   3:off   4:on    5:on    6:off
irda            0:off   1:off   2:off   3:off   4:off   5:off   6:off

— output truncated —

The first column gives the service name and further column gives the status of services at different run level starting from 1 to 6. Last script that will be executed is /etc/rd.d/rc.local. So any customization can be done in this script.

You can switch off or switch on any service for that run level using following command.

chkconfig <service_name> off | on

chkconfig acpid off

This will turn off acpid service, so next time when you reboot, it wont start acpid serivce which its supposed to start at run level 4 and 5.

system-config-services is the graphical interface to chkconfig.

Same things can be done using system-config-services tool.

Hope this helps !!


RHEL 5 Boot sequence and GRUB

Change is inevitable !!!

Having worked on Apps and database administration, its time to broaden the scope. I will be discussing few topics on RHEL (RedHat Entrprise Linux) system administration. Hope this will help beginners to gain knowledge about the most matured open source operating system available in the world.

Lets have a very quick review of how the Linux boots. Here are the very brief steps.

1) When a PC is booted it starts running a BIOS program which is a memory resident program on an EEPROM integrated circuit. The BIOS program will eventually try to read the first sector on a booting media such as a hard or floppy drive. The boot sector contains a small program that the BIOS will load and attempt to pass run control to. This program will attempt to read the operating system from the disk and run it.

2) The small program containing in the boot sector that BIOS will load and attempt to pass control to is called bootloader. This is a small program residing in the 1st sector of primary partition. Primary partition by default is always /boot. This directory will have all files required for bootup.

The boot loader program is present in 2 stages in Linux.

Stage 1: Small stage and resides in MBR (Master boot record) or boot sector. This is the once we were taking above – A small program residing in the 1st sector of primary partition /boot.

Stage 2: This is the complete bootup program present in /boot partiton and is called from first stage.

So 1st stage is present in MBR and just called for stage 2.

This MBR sector is 512 bytes size. The first 446 bytes contains the GRUB program (1st stage).

3) GRUB program reads the configuration file /boot/grub/grub.conf during boot time. Since this file is present in /boot partition, this partition should be present in file system that GRUB will understand, because it has to read the file before OS starts. So /boot mount point should be formated with either ext2 or ext3.

We will discuss about GRUB file shortly after finishing this brief booting sequence steps.

So once control comes to GRUB program it executes and you will see a red spashing windown comes up which gives the countdown in seconds like

Booting up Redhat Enterprise Linux in 5..4..3.. Secs

Now before the conuntdown ends, you can press either space or enter. Once you press that, you will see a table on a screen with list of operating systems present in that server. Example if you have installed Windows initially and then you installed Linux this table will show both OS in the option.

But to get this list of OS you need to enter space or enter, else it will bootup the default operating system which will be Linux.

This showing up of operating system list can be controlled by parameter hiddenmenu present in GRUB config file. We will see this in a short while. Also you can control the time for which it should countdown (timeout parameter in GRUB file).

GRUB will load the specific kernel into the RAM (which kernel to load is passed to GRUB in its script) and uncompress the kernel program in RAM. Once it uncompresses, the control is taken over by kernel and job of GRUB script ends here.

4) The kernel initialization files generates output which may not be possible to see on screen as it scrolls quickly but can be seen in log message file /var/log/dmesg which contains the snapsot of these kernel messages taken just after control is passed to init.

Many packages and device drivers present in kernel program are called. Device drivers will check all there respective hardware devices if they are available. If successful in locating devices, the driver will initialize and usually log output to kernel message buffer.

kernel of Linux is made light weight and hence will load only the required module and packages. But if some of the modules also needs to be loaded along with the kernel, its not a good idea to make it a part of kernel. Instead in redhat those additional modules are included in initrd file, which is then temporarily mounted by kernel on a RAM disk to make modules available for initialization process. This file initrd is password as one of the arguement in GRUB file for loading the kernel. We will see this arguement when we see GRUB file.

After all essential drivers are loaded, kernel will mount the root filesystem in read-only mode so that no process while booting should make any changes to any file on disk.

The first process is then created and loaded and control is passed from kernel to that process. This first process that gets created is called “init”. This process is having PID=1 and its the initialization process. This will intialize the system.

5) Init process created above will read its configuration file /etc/inittab. This file stores the information like initial run level, system initialization script, run level specific scripts, trap certain key sequences etc.
We will discuss about this file in my next post when I will explain run levels.

The final file that is run in boot sequence is /etc/rc.d/rc.local

So if we have to make any customization or call a custom script, we can call from this file. Example if we want to start a database when our server boots up we can add a script in /etc/rc.d/rc.local to start a database.

Having a brief idea about boot sequence for Linux, lets see the content of GRUB config file


The GRUB file in RHEL is present in /boot/grub/grub.conf

Following is the content of this file

# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
# Note that you do not have to rerun grub after making changes to this file
# NOTICE:  You have a /boot partition.  This means that
#          all kernel and initrd paths are relative to /boot/, eg.
#          root (hd0,0)
#          kernel /vmlinuz-version ro root=/dev/sda2
#          initrd /initrd-version.img
title Enterprise (2.6.9-
root (sd0,0)
kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.9-
title Enterprise-smp (2.6.9-
root (sd0,0)
kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.9-
title Enterprise-up (2.6.9-
root (sd0,0)
kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet
initrd /initrd-2.6.9-

lets understand meaning of each parameter here.

default -> This gives the default operating system to be booted in case the user is not giving any choice. Example if there are 2 OS installed on a server (lets say Linux and Windows, linux with number 0 and windows with number 1) then default=0 will boot Linux by default. The number is decided by the sequence in which these OS are listed in grub.conf above.

If we see the lines starting with “title”, these are the list of OS installed on server and this list (only the title) will be displayed at the time of booting when control goes from BIOS to GRUB. Since its present in grub.conf 1st stage of bootloader program will display this OS list.

In above file default=0 will pick “Enterprise (2.6.9-” OS by default.

timeout -> This gives the time for which countdown will continue or time for which the list of OS should be displayed before taking default option. Example in out case timeout=5 means it will show the option for 5 seconds.

splashimage -> This option gives a red spashing window of redhat linux while showing the list of OS or while booting. If you remove this file it will show a black window.

hiddenmenu -> This options will hide the list of OS installed on server. It will only show the countdown. If you press enter or space (as explained previously in point 3 of boot sequence) then it will show the list of OS. If you remove this option by default while booting it will show the list of OS installed.

title -> As explained just now these are the title to be shown during booting from where you can select. You can change title to anything that you want. Example “My OS”. This will show “My OS” as one of the option during booting.

root (sd0,0) -> This tells us that the boot loader program is present in 1st disk (sd0 indicate 1st hard disk) and 1st partition (,0 indicates 1st partition). So here we are telling where exactly is the bootloader program.

kernel /vmlinuz-2.6.9- ro root=LABEL=/ rhgb quiet

kernel is a parameter, /vmlinuz-2.6.9- is a value -> This is the name of kernel file to be used.

ro -> opens the filesystem in readonly mode during booting. If we remove this arguement it will open the filesystem in read write mode.

rhgb -> This is redhar graphical boot. This parameters gives a graphical progress bar while booting. If we remove this then it will give a traditional black window with many [ OK ] messages.

root=LABEL=/ -> This gives the location of root directory where all the installation has happened. this is usaully /. We can also give device name directly example in my case the device name is /dev/sda2. So we can give root=/dev/sda2
This will also work.

quiet -> This will hide details while booting up and will show only few message ehgb mode or in traditional mode. Only few [ OK ] messages will be displayed corresponding to services that are getting started. Else if we remove this parameter many more detailed messages will be displayed.

initrd /initrd-2.6.9- -> This gives the extended modules which we want to load while booting. As I explained that not all modules are part of kernel, in order to keep it light. So if additional extended modules needs to be intalled then we need to give this file as input.

My next post will be in run levels and understanding /etc/inittab file. Happy reading !!

Hope this helps !!