Follow us on facebook

Tuesday, 19 February 2013

INIT Process




The kernel, once it is loaded, finds init in sbin and executes it.
When init starts, it becomes the parent or grandparent of all of the processes that start up automatically on your Linux system. The first thing init does, is reading its initialization file, /etc/inittab. This instructs init to read an initial configuration script for the environment, which sets the path, starts swapping, checks the file systems, and so on. Basically, this step takes care of everything that your system needs to have done at system initialization: setting the clock, initializing serial ports and so forth.
Then init continues to read the /etc/inittab file, which describes how the system should be set up in each run level and sets the default run level. A run level is a configuration of processes. All UNIX-like systems can be run in different process configurations, such as the single user mode, which is referred to as run level 1 or run level S (or s). In this mode, only the system administrator can connect to the system. It is used to perform maintenance tasks without risks of damaging the system or user data. Naturally, in this configuration we don't need to offer user services, so they will all be disabled. Another run level is the reboot run level, or run level 6, which shuts down all running services according to the appropriate procedures and then restarts the system.


Linux Changing Run Levels
by NIXCRAFT on OCTOBER 16, 2005 · 4 COMMENTS
Available run levels are generally described in /etc/inittab, which is partially shown below:

#
# inittab   This file describes how the INIT process should set up
#           the system in a certain run-level.

# Default run level. The run levels 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:
<--cut-->


If you are moving to higher run levels, you may make additional services available to users, while moving to a lower run level will causes to services (daemons) to become unavailable. On the production server run level 3 is the normally used and rarely changed. However, some administrative tasks require the administrator to move system to run level 1 i.e single user mode.
Linux Find Out Current Run Level Command
Type the following command:
$ who -r
Sample outputs:
         run-level 2  2011-10-12 05:38  
Linux Change Run Level Command
Use the init command to change rune levels:
# init 1

Runlevel And Its Usage
The Init is the parent of all processes with PID # 1. Its primary purpose is to create processes from a script stored in the file /etc/inittab file. This file usually has entries which cause init to spawn gettys on each line that users can log in. A runlevel is nothing but a software configuration of the Linux system which allows only a selected group of processes to exist. The processes spawned by init for each of these runlevels are defined in the /etc/inittab file. Init can be in one of eight runlevels as follows:
§  Runlevel 0 is halt
§  Runlevel 1 is single-user
§  Runlevels 2-5 are multi-user (some distro uses RUN level 5 to start X [KDE/Gnome])
§  Runlevel 6 is for rebooting system
For example, typing the init 3 command will move system to run level 3:
# init 3
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























0 comments:

Post a Comment