Basics of Run Levels in Linux - BunksAllowed

BunksAllowed is an effort to facilitate Self Learning process through the provision of quality tutorials.

Random Posts

Basics of Run Levels in Linux

Share This
Run levels are represented by numbers in Unix-based systems. In each run level, a certain number of services are started or stopped.

There are seven-run levels in Unix systems, starting from zero to six. In the following table different run levels are stated in the way how different run levels are defined in different Linux distros. 

Though, run-levels 2 to 5 can be modified according to the user's choice.

0: Halt or shut down the system.
1: Single-user mode for special administration. Network interfaces are not configured at this level.
2: Local Multi-user with Networking but without network service (like NFS)
3: Full Multi-user with Networking
4: Not Used
5: Full Multi-user with Networking and X Windows(GUI)
6: Reboot.

The Services that get started at a certain run-level are determined by the contents of rcN.d directories. Here, N represents run level. Generally, the location of rcN.d directory is either /etc/init.d/rcN.d or /etc/rcN.d. . The location is dependent on distribution. The value N is within the range of 0 to 6
The list of run levels can be checked by executing the following command.

The start-up scripts are located in /etc/init.d . At each run level, a series of links point to start-up scripts. The names of these links start either by K or S , followed by a number. S indicates that the service will be started when you go into that run level and K indicates that the service will be killed if running. 
The number following the K or S indicates the order the scripts will be run. Here is a sample of what an /etc/rc0.d may look like. 

Here, init stands for initialization. 

The default run levels are set in /etc/inittab file. Linux systems run with GUI in run-level 5. Whereas, in run-level 3, GUI is not available. If the system needs to be shut down, init 0 is executed. Similarly, init 6 is executed to reboot the system. 

The tool chkconfig is used to control the services to be started at specific run levels. To check a list of services, which are enabled or disabled at specific run levels, the chkconfig -list command is used. 

Happy Exploring!

No comments:

Post a Comment