Thursday 2 February 2012

Runlevels in Linux

                     The Linux services are organized by runlevels. There are seven runlevels and each runlevel executes a specified set of scripts. All scripts are collectively stored in /etc/rc.d/init.d directory and all runlevels also have their own directory which contains some start and stop scripts. The scripts associated with each runlevel can be found in /etc/rc.d directory:


Runlevel and description of each runlevel is given below:

Runlevel                 Description

   init 0                    Halt (Do not set initdefault to this)

   init 1                    Single-user mode, for maintenance, repairs,backups and restores.

   init 2                    Multiuser with some networking services ( for system performance)

   init 3                    Multiuser with networking

   init 4                    Unused (customized to use)

   init 5                    X11 console, Defaults to a GUI desktop with networking

   init 6                    Reboot (Do not set initdefault to this)

To list all runlevels

cat /etc/inittab

To switch particular runlevel

init x    (eg. init 6 - to reboot)

To list all service settings run the following command:

/sbin/chkconfig --list

To list the entry for the sshd daemon, execute the following command:

/sbin/chkconfig --list | grep sshd

To know which services get started for runlevel 3:

/sbin/chkconfig --list | grep '3:on'

The httpd service to start up at runlevel 5 we would issue the following command:

/sbin/chkconfig --level 5 httpd on

To see graphical tool that allows you to view which services will start for each runlevel


Otherwise go to System - Administration - Services

The graphical tool also allows you to start, stop, restart, enable, disable each services and to customize the services for particular runlevels.


No comments:

Post a Comment