A small journey of the Linux important file /etc/inittab

A small journey of the Linux important file /etc/inittab

Share Now
2 min read
51
What is the file /etc/inittab, why is it so important.

Let’s think of some situation, you have a server, you are unable to get the login prompt once it boots successfully. These mechanisms are controlled by some configuration which is written on /etc/inittab file. Let`s try to understand that in more detail.

As we know when Linux Kernal loads itself to the memory, it tries to execute and initialize the underlying hardware. It then mounts the root (/) file system.
That’s not the end, Kernal even tries to initialize the very first process into the Linux and that is init process. (That’s why it gets an id as 1)

The init process starts the Linux server based on the default runlevel that is set.
It follows its configuration file under /etc named /etc/inittab
The configuration file (/etc/inittab) defined 3 main items for the init process.
It defines the default runlevel.

Which process and service to start and monitor
How to handle the system when it enters into a different runlevel/etc/inittab file is contained with the below format
identifier:runlevel:Action:Command

Some commands are
Respawn
Wait
Once
Boot
Off

/etc/inittab ubuntu

1. Id:3:initdefault: This defines the default runlevel is set to 3.

2. System initialization : si::sysinit:/etc/rc.d/rc.sysinit

a. This defines the system to run a script (/etc/rc.d/rc.sysinit) when the system boots up.
b. The script initializes the system.
c. The script has some commands which help mount the proc file system.
d. The script initializes the keyboard maps, console font, NIS domain, hostname, and swap partition
e. This script runs only during the boot.

3. l3:3:wait:/etc/rc.d/rc 3

a. L3 — > It is a descriptive and can be anything
b. 3 → list of run level under which the script should be executed(/etc/rc.d/rc 3)
c. Wait — > Wait till /etc/rc.d/rc completes its execution

4. co:2345:respawn:/sbin/agettyxvc0 9600 vt100-nav

a. Getty is nothing but get tty, this is used during login to provide login prompt to the user and that invokes the /bin/login command
b. This means, run the command /sbin/agetty xvc0 9600 vt100-nav
c. This should run the command in any runlevel between 2 to 5(2345)
d. respawn means to restart the process if it dies.

Summary about init process:
  • Kernel loads itself to Memory
  • Kernel initializes hardware
  • Kernel executes /sbin/init process and PID 1
  • Init executes all scripts for its default run level
  • Init spawns Getty programs on each terminal
  • Getty prompts for login
  • Getty executes /bin/login to authenticate the user
  • Login starts the shell

Use case: One fails to connect to a VM from vmware console, but able to connect to the VM using ssh.
This could be related to /ect/inittab where the Getty configuration needs to check.

To get know more details about Linux contact us Lia Infraservices. Any tips or feedback please let us know in the comments!!

Leave comment

Your email address will not be published. Required fields are marked with *.