A 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. Conventionally, seven runlevels exist, numbered from zero to six.
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.
Run Level | Action | |
---|---|---|
0 | Halt | Shuts down system |
1 | Single-User Mode | Does not configure network interfaces, start daemons, or allow non-root logins |
2 | Multi-User Mode | Does not configure network interfaces or start daemons. |
3 | Multi-User Mode with Networking | Starts the system normally. |
4 | Undefined | Not used/User-definable |
5 | X11 | As runlevel 3 + display manager(X) |
6 | Reboot | Reboots the system |
Most Linux servers lack a graphical user interface and therefore start in runlevel 3. Servers with a GUI and desktop Unix systems start runlevel 5. When a server is issued a reboot command, it enters runlevel 6.
Init scripts
Init (short for initialization) is the program on Unix and Unix-like systemsThe Init is the parent of all processes with 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.
Linux Find Out Current Run Level Command
Type the following command:
$ who -r
Linux Change Run Level Command
Use the init command to change rune levels:
# init 1
On most Linux server system default run level is 3 and on most Linux Desktop system default run level is 5. The default run level is defined by the initdefault line at the top of /etc/inittab file under CentOS / Fedora / Redhat / RHEL / Debian Linux. To change the default run level, edit /etc/inittab file, and edit entry initdefault:
# vi /etc/inittab
Set initdefault to 5, so that you can boot to X next time when Linux comes up:
id:5:initdefault:
Save and close the file. Reboot the system to see changes:
# reboot
Identifying Services that Start at Each Runlevel
There are number of ways to identify which services get started without having to delve into the /etc/rc.d sub-directories. The command line tool chkconfig (usually located in the /sbin directory) can be used to list which services get started at boot time. To list all service settings run the following command:
/sbin/chkconfig --list
0 comments:
Post a Comment