so , what's the meaning of Runlevels?
Runlevels define what services or processes should be running on the system.
in other words : A runlevel is a software configuration of the system that allows only a selected group of processes to exist, Init can run the system in one of 6 runlevels.
so, what's the init?
Init is the parent of all processes on the system, it is executed by the kernel and is responsible for starting all other processes, it is the parent of all processes whose natural parents have died and it is responsible for reaping those when they die.
The init process reads the file “/etc/inittab” and uses this file to determine how to create processes. Also, note that init is always running and can dynamically do things and run processes based upon various signals. The administrator can also cause it to dynamically change system processes and runlevels by using the init program or editing the “/etc/inittab” file.
right, we informed that can run the system in one of 6 runlevels.These runlevels are 0-6. The system runs in only one of these runlevels at a time. Typically these runlevels are used for different purposes. Runlevels 0, 1, and 6 are reserved. For Redhat Linux . the runlevels are:
| Init Level | Demonstration |
|---|---|
| 0 | Shut down system, power-off if hardware supports it (only available from the console) |
| 1 | Single-user mode , only open the /bin/bash (using this level if there was problems in the system) |
| 2 | Multi-user mode with networking |
| 3 | Full-multi-user mode (with RFS:Remote File System and NFS:Network File System) |
| 4 | Multi-user,user defined (used under special circumstances) |
| 5 | Multi-user mode with GUI (Running as default) |
| 6 | Reboot |
Let’s go to the Implementation part
the command
#init <RunLevel>
will change our current run level to the run level we put where <RunLevel> one of the values in the table above
if i need to know what’s the current run level running just type
#runlevel
N 5
the previous example show that the system runlevel is “5″
if we need to change the default runlevel .so, just vim the file /etc/inittab
this file will opened.
# Terminal gettys (tty[1-6]) are handled by /etc/event.d/tty[1-6] and
# /etc/event.d/serial
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(8), initctl(8), and events(5).
#
# Default runlevel. The runlevels used are:
# 0 - halt (Do NOT set initdefault to this)
# 1 - Single user mode
# 2 - Multiuser, without NFS (The same as 3, if you do not have networking)
# 3 - Full multiuser mode
# 4 - unused
# 5 - X11
# 6 - reboot (Do NOT set initdefault to this)
#
id:5:initdefault:
we see at the last line id:5:initdefault: just change the value 5 to your prefer runlevel and save.
There will be a time when you want to know what services are running, and the different runlevels they are specified in. You can use a simple command to display a list of all runlevels and services used by them.
just type
#chkconfig --list
the out put will be like this
NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
anacron 0:off 1:off 2:on 3:off 4:on 5:on 6:off
atd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
auditd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
avahi-daemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
bluetooth 0:off 1:off 2:off 3:on 4:on 5:on 6:off
cpuspeed 0:off 1:on 2:on 3:on 4:on 5:on 6:off
crond 0:off 1:off 2:on 3:on 4:on 5:on 6:off
cups 0:off 1:off 2:on 3:on 4:on 5:on 6:off
dnsmasq 0:off 1:off 2:off 3:off 4:off 5:off 6:off
firstboot 0:off 1:off 2:off 3:off 4:off 5:off 6:off
gpm 0:off 1:off 2:on 3:on 4:on 5:on 6:off
haldaemon 0:off 1:off 2:off 3:on 4:on 5:on 6:off
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off
ip6tables 0:off 1:off 2:on 3:on 4:on 5:on 6:off
the first column: determine the service name
the other six colums:determines the service status in all runlevels (on | off)
let’s use this output for other useful command
NetworkManager 0:off 1:off 2:on 3:on 4:on 5:on 6:off
we see that the networkmanager service is off in runlevels (0,1 and 6) and on in the others
so we want to close the service in runlevel(3)
just type this command
#chkconfig --level 3 NetworkManager off
if we want to re open just change off to on
Tags: Linux, Linux Run Levels
June 29, 2009 at 12:49 am |
Nice Topic,
Thanks
August 12, 2009 at 1:19 am |
good