LINUX Runlevels

LINUX Runlevels

runlevel is one of the modes that a Unix-based operating system will run in. Each runlevel has a certain number of services stopped or started, giving the user control over the behavior of the machine. 

After the Linux kernel has booted, the init program reads the /etc/inittab file to determine the behavior for each runlevel. Unless the user specifies another value as a kernel boot parameter, the system will attempt to enter (start) the default runlevel.

At any given time, the system is in one of eight possible run levels.

Processes spawned  by init for each of these run levels are defined in /etc/inittab. init can be in one of eight  run  levels,  0-6 and  S  or  s (S and s are identical). The run level changes when a privileged user runs /sbin/init. 

 

Runlevel

Description

 

init 0

System halt/shutdown

The system can be safely powered off with no activity.

poweroff.target

init 1

Single user mode

emergency mode (no network)

no multitasking

only root has access in this runlevel 

 rescue.target

init 2

 No network but multitasking

User-defined/Site-specific runlevels.

By default, identical to 3.

multi-user.target

init 3

Multi-user

Command mode

 

multi-user.target

init 4  

 No network but multitasking

It is reserved for other purposes in research. 

multi-user.target

init 5

Network Mode

Multitasking mode

GUI

sound

graphical.target

init 6

reboot

reboot.target

 

init s   : Tells the init command to enter the maintenance mode. When the 

system enters maintenance mode from another run level, only the system console 

is used as the terminal. 

init S  : Same as init s. 

init m : Same as init s and init S. 

init M : Same as init s or init S or init m. 

 We can take it from above that 4 options(S,s,M,m) are synonymous. 

 

Init scripts

Init (short for initialization) is the program on Unix and Unix-like systems that spawns all other processes. It runs as a daemon and typically has PID 1.

 

The /etc/inittab file is used to set the default run level for the system. This is the runlevel that a system will start up on upon reboot. The applications that are started by init are located in the /etc/rc.d folder. Within this directory there is a separate folder for each run level, eg rc0.d, rc1.d, and so on.

chkconfig

The chkconfig tool is used in Red Hat based systems (like CentOS) to control what services are started at which runlevels. Running the command chkconfig –list will display a list of services whether they are enabled or disabled for each runlevel.

Single User mode

It is a mode that a multi-user system (like a Linux server) can be booted into the operating system as a superuser. Booting a system into this mode does not start networking, but can be used to make changes to any configuration files on the server. One of the most common usages for single-user mode is to change the root password for a server on which the current password is unknown.

Conclusion

Runlevels are an important part of the core of the Linux operating system. While not something the average administrator will work with on a daily basis, understanding runlevels gives the administrator another layer of control and flexibility over the servers they manage.



Md. Masud Rana Suman

Md. Masud Rana Suman

I am Microsoft Certified Professional(MCP), Microsoft Certified Solution Associate:Windows Server 2012. ‏‏‎ <br/> <br/> Providing IT support from the year 2013, Which includes Operating System(Windows) support, Networking Services, WHM (Web Hosting Manager) support, WEB Hosting and Domain Name Registration services, Email Server configuration, Information Management Services, Data Recovery, Social Media Marketing, Trainer and many more...
spoofing

Spoofing

rbillah | 02/09/2020 22:52