Saturday, July 17, 2010

/etc Directory

/etc directory contains configuration files of all the programs and services that run in a linux machine. A Linux service is an application (or set of applications) that runs in the background waiting to be used, or for carrying out essential tasks. This directory is one of the most used directories by the system administrators. There are many useful files and directories that are used by a system administrator on a day-day basis.

How does a system administrator tell what services are running, and more importantly, how does he set up one of his own?

Let's start by looking at how the system is set up, and in particular at the directory /etc/rc.d. Here you will find either a set of files named rc.0, rc.1, rc.2, rc.3, rc.4, rc.5, and rc.6, or a set of directories named rc0.d, rc1.d, rc2.d, rc3.d, rc4.d, rc5.d, and rc6.d. You will also find a file named /etc/inittab. The system uses these files (and/or directories) to control the services to be started.

The file /etc/inittab will have entries something like this:

id:4:initdefault:l

0:0:wait:/etc/rc.d/rc.0l

6:6:wait:/etc/rc.d/rc.6x

1:4:wait:/etc/rc.d/rc.4


The boot process uses these parameters to identify the default runlevel and the files that will be used by that runlevel. In this example, runlevel 4 is the default and the scripts that define runlevel 4 can be found in /etc/rc.d/rc.4.

Runlevel is the point at which the system is entered. Runlevel 1 is the most basic configuration (Simple single user access using an text interface), while Runlevel 5 is the most advanced (multi-user, networking and a GUI front end). Runlevels 0 and 6 are used for halting and rebooting the system.

System Boot Process:
When booting multi-user, the kernel runs init (located in /sbin/init), which spawns a shell (/bin/sh) to run /etc/rc, which contains commands to check the consistency of the file-systems, mount the disks, start up system processes, etc. /etc/rc invokes /etc/netstart to configure the network and any associated services, and /etc/rc.local (if it exists) for locally added services.
After /etc/rc has successfully completed, init forks a copy of itself for each terminal in /etc/ttys, usually running /usr/libexec/getty on them. Administrative configuration of system services is controlled by editing the scripts (/etc/rc, /etc/rc.local, /etc/netstart). In some instances, only shell variables need to be changed, in others commands are added, changed, or removed.



/etc/rc

No comments:

Post a Comment