System Operating Procedure: RedHatlinuxinittab

Source: Internet
Author: User
Article Title: system operating program: RedHatlinuxinittab. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.

1. What is init?

Init is an indispensable program in Linux. Is a user-level process started by the kernel.

After the kernel is started (it has been loaded into the memory, started to run, and initialized to all the device drivers and data structures, start a user-level program init to start other user-level processes or services. Therefore, init is always the first process (its PID is always 1 ).

In the past, the kernel used init to find it. The correct position (for Linux) is/sbin/init. If the kernel cannot find init, it will try to run/bin/sh. If the run fails, the system will also fail to start.

Ii. Operation Level

The running level is the function level that the operating system is currently running. This level ranges from 1 to 6 and has different functions. Its function level is as follows:

#0-stop (never set initdefault to 0)

#1-single-user mode

#2-multiple users without NFS

#3-full multi-user mode (Standard Operation Level)

#4-useless

#5-X11 (xwindow)

#6-Restart (do not set initdefault to 6. Setting initdefault to 0 or 6 is a denial of service attack !)

In addition, there are three ABC running levels, but it does not make sense in RHLinux.

These levels are specified in the/etc/inittab file. This file is the main file found by the init program. The first service to run is the file stored in the/etc/rc. d directory. In most Linux releases, the startup script is located in/etc/rc. d/init. d. These scripts are connected to the/etc/rc. d/rcn. d directory by using ln commands. (Here n is the running level 0-6)

3. Run-level Configuration

The running-level configuration is performed in the/etc/inittab line, as shown below:

12: 2: wait:/etc/init. d/rc 2

The fields are described as follows:

Id: runlevels: action: process

Id: it is a sequence number of any specified four characters. It must be unique in this file. Use libc5 (earlier than 5.2.18) or. the sysvinit compiled by the out library is limited to 2 characters. Note: Login processes such as getty must make the id field consistent with the tty number. For example, tty1 requires id = 1. Many earlier login processes follow this rule.

Runlevels: indicates the level at which the row is applicable (here it is 2, there can be multiple, indicating that the row needs to be run at the corresponding running level ); in addition, the sysinit, boot, and bootwait processes ignore this setting value.

Action: indicates how to run the process field command when entering the corresponding runlevels. The common field values and explanations are in the appendix. In this example, wait indicates that you need to run the process once and wait for it to end.

Process: The specific command to be executed. In the example,/etc/init. d/rc commands start the processes/commands that should be run in runlevel 2 and terminate them when they exit the runlevel (except for the programs that are still running at runlevel .)

When the running level changes and the running program is not specified in the new running level, init will first send a SIGTERM signal to terminate and then SIGKILL.

The valid action values are as follows:

Respawn: indicates that init should monitor this process, even after which it should be restarted.

Wait: init should run the process once and wait until it is finished before proceeding to the next step.

Once: init needs to run this process once.

Boot: run as the system starts, so the runlevel value is invalid.

Bootwait: run as the system starts, and init should wait until it ends.

Off: it makes no sense.

Initdefault: the default running level after the system is started. As processes at the corresponding running level are activated, the process field specified by the system is meaningless. If this record does not exist in the inittab file, you can query the running level on the console when the system starts.

Sysinit: the command to be run when the system starts. For example, this command will clear/tmp. You can check the/etc/rc. d/rc. sysinit script to learn about the operations it is running.

Powerwait: Allows init to shut down the system when the power supply is disconnected. Of course, the premise is that u p s and monitoring u p s and notifying init that the power supply has been cut off. This option is not listed by default in RH linux.

Powerfail: Same as powerwait, but init does not wait until the running process ends. This option is not listed by default in RH linux.

Powerokwait: The operation that init performs when the power monitoring software reports "power recovery.

Powerfailnow: If the ups power supply is about to run out, the init operation is different from powerwait/powerfail.

Ctrlaltdel: Allows init to restart the system when you press the C t r l + A l t + D e l key combination on the console keyboard. Note: If the system is deployed in A public place, the system administrator can configure the C t r l + A l t + D e l combination key as another action, such as ignore. I set it to print out a swearing sentence ^ o ^.

Kbrequest: monitors the actions taken when a specific keyboard combination key is pressed, which is not complete yet.

Ondemand: A process marked with an ondemand runlevel will be executed whenever the specified ondemand runlevel is called. however, no runlevel change will occur (ondemand runlevels are 'A', 'B', and 'C. Shame !)

Supplement:

1. for single-user mode, you can set initdefault to 1 or specify a single or emergency command line parameter in grub/lilo. In fact, there is another cleaner method. Edit:

Kernel/vmlinuz-2.6.9-22.EL ro root =/bin/sh, so init starts a shell directly, no other process is started Oh, clean enough!

2. When the system is running, the telinit command can change the running level. When the running level changes, init runs the corresponding command from/etc/inittab.

Reference:

Think machine: Linux init detailed description ZT

Man inittab

Related Article

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.