Details about the process initialization configuration file inittab in Linux

Source: Internet
Author: User
Tags sigint signal terminates

The/etc/inittab file describes which processes are starting and running correctly. Inittab the configuration file used by the INIT initialization program for Linux initialization of the file system. This file is responsible for setting up where the Init initialization script is being initialized, and the commands that run when each run level initializes; Power on, shutdown, restart the corresponding command, the operation level of the log when the command.

The entries in the Inittab file are formatted as follows:

1.label
Label is a unique sequence that determines an entry of 1-4 characters, and some systems support only 2-character labels. For other login program items such as Getty or Mingetty, the label is required to be the same as the TTY number, otherwise the Getty program will not function correctly.

Common labels are:

ID used to define the level of default Init run
Si is the process of system initialization
ln where n is 1~6, indicating the level of runlevel that the process can use
UD is the upgrade process
The CA indicates the process that runs when Ctrl+alt+del is pressed
PF refers to a process that is run when a UPS indicates a power outage
PR is a process that needs to be run before the system actually shuts down and the UPS signals a power recovery
X is the process that needs to be run when the system is transferred to the X terminal

2.runlevels
Runlevels lists the run level, specifying the actions that should be taken. You can specify multiple runlevel levels, or you can specify a specific value for the RunLevel field.

RunLevel 0 is to have init shut down all processes and terminate the system.
RunLevel 1 is used to transfer the system to Single-user mode, single user mode can only be access to the system administrator, in this mode to handle those who have logged in to the user can not make changes to the file, the RunLevel number 1 can also be replaced with S.
RunLevel 2 is a mode that allows the system to enter multiple users, but does not support file sharing, which is rarely applied.
RunLevel 3 is the most common mode of operation, which is used primarily to provide a true multiuser pattern and the default mode for most servers.
RunLevel 4 is not typically used by the system, and users can design their own system state and apply it to the RunLevel 4 phase, although rarely used, but use the system to implement some specific logon requests.
RunLevel 5 is to initialize the system to a dedicated X Window terminal. This is not a good choice for a powerful Linux system, but it can also be implemented by starting at RunLevel if the user wants to.
RunLevel 6 is to close all running processes and reboot the system.

Debian6 default is not run/etc/inittab file default level is 2-5

3.action
The Action field defines the state in which the process should run, and describes how subsequent processes are run. :

Respawn Restart the process whenever it terminates
Wait run process waits for input run mode This procedure will start a run level when the specified input and init will wait for it to terminate
Once every runlevel level run this procedure will execute once when the specified input RunLevel
Boot runs at system startup, ignoring RunLevel
Bootwait runs at system startup and Init waits for the process to complete. Ignore RunLevel
Ctrlaltdel when Ctrl+alt+del three keys are pressed at the same time, the SIGINT signal is sent to Init. Ignore RunLevel
Initdefault do not execute this process, it is used to set the default RunLevel
Kbrequest is run when Init receives a signal from the keyboard. This requires the keyboard combination to match the Keyboardsigra
Off prevents entry, so the process does not run
Once run once per RunLevel level
OnDemand when the system specifies specific run levels A, B, and C run
Powerfail when Init receives the SIGPWR signal, it runs
Powerokwait run when the SIGPWD signal is received and the power state in the/etc/file contains OK
Powerwait when the SIGPWD signal is received and Init waits for the process to run at the end
Sysinit run before running the boot or bootwait process

4.process
The process field contains processes that are executed by INIT, in a format similar to that of running the process at the command line, so that the process field starts with the name of the procedure, followed by the parameters to be passed to the process at run time.

The code is as follows:
#/etc/inittab:init (8) configuration.
# $Id: inittab,v 1.91 2002/01/25 13:35:21 miquels EXP $

The code is as follows:

# the default runlevel.
Id:2:initdefault: #表示当前缺省运行级别为2

The code is as follows:

# Boot-time System configuration/initialization script.
# This is run a except when booting in emergency (-B) mode.
Si::sysinit:/etc/init.d/rcs #系统初始化的进程

The code is as follows:

# What to does in Single-user mode.
~~:s:wait:/sbin/sulogin

The code is as follows:

#/ETC/INIT.D executes the S and K scripts upon change
# of RunLevel.
#
# RunLevel 0 is halt.
# runlevel 1 is single-user.
# Runlevels 2-5 are multi-user.
# RunLevel 6 is reboot.

The code is as follows:

L0:0:WAIT:/ETC/INIT.D/RC 0
L1:1:WAIT:/ETC/INIT.D/RC 1
L2:2:WAIT:/ETC/INIT.D/RC 2
L3:3:WAIT:/ETC/INIT.D/RC 3
L4:4:WAIT:/ETC/INIT.D/RC 4
L5:5:WAIT:/ETC/INIT.D/RC 5
L6:6:WAIT:/ETC/INIT.D/RC 6
# normally not reached, but fallthrough into case of emergency.
Z6:6:respawn:/sbin/sulogin

The code is as follows:

# What to did when Ctrl-alt-del is pressed. #在启动过程中是否允许按CTRL-alt-delete reboot System
#ca: 12345:ctrlaltdel:/sbin/shutdown-t1-a-R now

The code is as follows:

# Action on Special keypress (Alt-uparrow).
#kb:: Kbrequest:/bin/echo "keyboard request--edit/etc/inittab to let this work."

The code is as follows:

# What to doing when the power fails/returns.
PF::p owerwait:/etc/init.d/powerfail Start
PN::p Owerfailnow:/etc/init.d/powerfail now
PO::p owerokwait:/etc/init.d/powerfail Stop

The code is as follows:

#/sbin/getty invocations for the runlevels.
#
# The ' id ' field must is the same as the last
# Characters of the device (after "TTY").
#
# Format:
# <id>:<runlevels>:<action>:<process>
#
# Note This on most Debian systems Tty7 are used by the X Window System,
# So if you are want to add more Getty's go ahead but skip Tty7 if you run X.
# Getty Process to provide services for virtual terminal equipment
1:2345:respawn:/sbin/getty 38400 Tty1

The code is as follows:

#标签字段的值是1, 1 is the digital suffix of the device tty1, Tty1 is associated with the corresponding process, the runlevel that the Getty process can start is 2,3,4 and 5, and when the process terminates, Init restarts it immediately. The path name of the startup process is/sbin/getty, which is the smallest version of the Getty that implements the virtual terminal support, providing tty1 with the process to start the virtual device.
2:23:respawn:/sbin/getty 38400 Tty2
#3:23:respawn:/sbin/getty 38400 tty3
#4:23:respawn:/sbin/getty 38400 Tty4
#5:23:respawn:/sbin/getty 38400 tty5
#6:23:respawn:/sbin/getty 38400 tty6
# Example to put a Getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty-l ttyS0 9600 vt100
T1:23:respawn:/sbin/getty-l ttyS1 115200 vt100
# Example to put a Getty in a modem line.
#
#T3:23:respawn:/sbin/mgetty-x0-s 57600 ttyS3

5. Example

The code is as follows:

# begin/etc/inittab
Id:3:initdefault:
si::sysinit:/etc/rc.d/init.d/rc sysinit
l0:0:wait:/etc/rc.d/ INIT.D/RC 0
L1:S1:WAIT:/ETC/RC.D/INIT.D/RC 1
L2:2:WAIT:/ETC/RC.D/INIT.D/RC 2
l3:3:wait:/etc/rc.d/init.d/ RC 3
L4:4:WAIT:/ETC/RC.D/INIT.D/RC 4
L5:5:WAIT:/ETC/RC.D/INIT.D/RC 5
L6:6:WAIT:/ETC/RC.D/INIT.D/RC 6
Ca:12345:ctrlaltdel:/sbin/shutdown-t1-a-R now
Su:s016:once:/sbin/sulogin
1:2345:respawn:/sbin/agetty tty1 9600
2:2345:respawn:/sbin/agetty tty2 9600
3:2345:respawn:/sbin/agetty tty3 9600
4:2345:respawn:/sbin/ Agetty Tty4 9600
5:2345:respawn:/sbin/agetty tty5 9600
6:2345:respawn:/sbin/agetty tty6 9600
# End/etc/initt AB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.