• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer navigation

The Geek Diary

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • VCS
  • Interview Questions
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
  • DevOps
    • Docker
    • Shell Scripting
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

Understanding the /etc/inittab File in Linux

by admin

When System V-style init programs are started by the kernel, they read their configuration file, /etc/inittab. This file defines:

  • the runlevel in which init will start the system by default
  • programs init will run to initialize the system
  • standard processes init will start for each runlevel
  • scripts init will run to implement each runlevel

By default, most servers are started in runlevel 3, while most workstations are started in runlevel 5. This default can be overridden at boot time by configuring the bootloader to pass init an option specifying an alternate runlevel.

/etc/inittab Line Syntax

A line in the /etc/inittab file has four fields that are colon delimited.

id:rstate:action:process

– The first is a unique ID. It doesn’t matter what the value is as long as no other line has the same 1 or 2 characters.
– The second is the list of runlevels to restrict this line to. If none are listed, the line will be processed regardless of the default runlevel.
– The third field is the action that will be taken (usually executing the command specified in the fourth field).

The following table describes the fields in an inittab entry.

Field Description
id Is a unique identifier for the entry.
rstate Lists the run levels to which this entry applies.
action Identifies how the process that is specified in the process field is to be run. Possible values include: sysinit, boot, bootwait, wait, and respawn. For a description of the other action keywords, see inittab(4).
process Defines the command or script to execute.

Default Runlevel

The initdefault line in /etc/inittab tells init which runlevel to go to if it has not been given that information. This line is special in that there is no command to run (all others have a value in the fourth fiedl):

Sample /etc/inittab file

Below is a sample /etc/inittab file from CentOS 6 system.

# cat /etc/inittab 
# inittab is only used by upstart for the default runlevel.
#
# ADDING OTHER CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.
#
# System initialization is started by /etc/init/rcS.conf
#
# Individual runlevels are started by /etc/init/rc.conf
#
# Ctrl-Alt-Delete is handled by /etc/init/control-alt-delete.conf
#
# Terminal gettys are handled by /etc/init/tty.conf and /etc/init/serial.conf,
# with configuration in /etc/sysconfig/init.
#
# For information on how to write upstart event handlers, or how
# upstart works, see init(5), init(8), and initctl(8).
#
# 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:3:initdefault:

/etc/rc.d/rc.sysinit Boot Script

The /etc/rc.d/rc.sysinit script is called by the init program on boot. This script performs initial setup that is run-level agnostic. The following are examples of things done by the rc.sysinit script:

  • peripheral hardware such as USB, parallel or serial connected devices are configured
  • kernel parameters which are specified in /etc/sysctl.conf get applied to the running kernel
  • Sets the hostname
  • the root filesystem is checked and remounted read/write
  • RAID and LVM devices are activated
  • Swap files and partitions are activated
  • disk quotas activated

Filed Under: CentOS/RHEL 6, Linux, OEL 6

Some more articles you might also be interested in …

  1. lvmconf Command Examples in Linux
  2. How to scan newly Assigned LUNs in Multipathd under CentOS / RHEL
  3. How to extract RPM package without installing it
  4. pinky Command Examples in Linux
  5. ‘nestat -s’ showing a large number for “packet reassembles failed” errors in CentOS/RHEL
  6. How to Configure Separate Port For SSH and SFTP On CentOS/RHEL
  7. fdisk Command Examples in Linux
  8. How to work with multiple java versions under Linux
  9. Downloading RPM Packages with dependencies [ yumdownloader Vs yum-downloadonly Vs repoquery]
  10. How To Change Timezone for Oracle Grid Infrastructure

You May Also Like

Primary Sidebar

Recent Posts

  • JavaFX ComboBox: Set a value to the combo box
  • Nginx load balancing
  • nginx 504 gateway time-out
  • Images preview with ngx_http_image_filter_module

© 2022 · The Geek Diary

  • Archives
  • Contact Us
  • Copyright