Home  >  Article  >  System Tutorial  >  Introducing the inittab file of CentOS and how to set it up at boot

Introducing the inittab file of CentOS and how to set it up at boot

王林
王林forward
2024-01-06 17:37:09495browse

English explanation in /etc/inittab under CentOS:

This file describes how the INIT process should set up the system in a certain run-level.The inittab file describes which processes are started at bootup and during normal operation.

In layman's terms, it means controlling some programs and levels when Linux starts.

English explanation of run-level:

# Default runlevel. The runlevels used by RHS 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)

Translate the above to:

# 0 - shutdown (never set initdefault to 0)

# 1 - Single User Mode

# 2 - Multi-user, no NFS (no network)

# 3 - Full multi-user mode (standard run level, actually text mode)

# 4 - Not used

# 5 - X11 (xwindow)

# 6 - Restart

All valid statements in the inittab file follow the following format:

id:runlevels:action:process

id: is the identification name, you can name it arbitrarily, within 4 characters. It should be noted that the identification name cannot be repeated, it is unique.

runlevels: Indicates which levels this line is suitable for running (the 6 levels shown above); in addition, the three processes of sysinit, boot, and bootwait will ignore this setting value. You can select multiple options for this item. For example, if you want to run levels 1, 2, and 3, write 123

action: Indicates how init should run the command in the process field when entering the corresponding runlevels. Commonly used field values ​​and explanations are in the appendix.

respawn: Indicates that init should monitor this process and it should be restarted even after it ends.

wait: init should run this process once and wait for it to end before proceeding to the next step.

once: init needs to run this process once.

Boot: Runs when the system starts, so the runlevel value is invalid for it.

Bootwait: Runs when the system starts, and init should wait for it to end.

Off: Doesn’t make any sense.

initdefault: The default run level after system startup; since entering the corresponding run level will activate the process of the corresponding level, the process field specified in it has no meaning. If this record does not exist in the inittab file, the system will ask the console for the entered runlevel when it starts.

sysinit: The command to be run when the system starts. For example, this command will clear /tmp. You can view the /etc/rc.d/rc.sysinit script to see what operations it performs.

powerwait: Allow init to shut down the system when the power is cut off. Of course, the premise is that there is UPS and software that monitors UPS and notifies init that the power has been cut off. RH linux does not list this option by default.

Powerfail: Same as powerwait, but init will not wait for the running process to end. RH linux does not list this option by default.

powerokwait: The operation to be performed by init when the power monitoring software reports "power restored".

Powerfailnow: When it detects that the ups power supply is about to run out, the operation to be performed by init is different from powerwait/powerfail.

ctrlaltdel: Allow init to restart the system when the user presses the C t r l A l t D e l key combination on the console keyboard. Note that if the system is placed in a public place, the system administrator can configure the C t r l Alt Del key combination to have other behaviors, such as ignoring it. I set it to print a curse word^o^. kbrequest: Monitor the action taken when a specific keyboard key combination is pressed. It is not perfect 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’)

process: It is the executed program

Example:

id:3:initdefault:                   #Indicates entering the command line mode after startup

x:5:once:/etc/X11/prefdm -nodaemon #Indicates that prefdm -nodaemon will be executed once in xwindow mode after startup

Practical experience:

If you want to boot directly into "command line mode", you can edit the /etc/inittab file and set it to id:3:initdefault:

If you want to enter "window mode" directly, set it to id:5:initdefault:

The above is the detailed content of Introducing the inittab file of CentOS and how to set it up at boot. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:jb51.net. If there is any infringement, please contact admin@php.cn delete