Inittab file profiling [centos 5.x] (version 2)

Source: Internet
Author: User
Tags dmesg
Inittab file profiling [centos 5.x]



Grep-V "^ #"/etc/inittab | more # filter out rows starting #

 

Inittab File Format

ID: runlevels: Action: Process

ID: identifier, generally two digits or letters

Runlevels: indicates the running level. You can specify multiple runlevels. If it is null, the value ranges from 0 ~ 6. Execute all running levels

Action: Specifies the running status

Process: Specifies the script or command to run.

 

/Etc/inittab body analysis

Statement 1:

ID: 5: initdefault:

Initdefault: Specifies the default startup running level and the default startup command.

5: You can change it to 3. The default startup character interface, instead of starting the graphic interface.


Statement 2:

Si: sysinit:/etc/rc. d/rc. sysinit


/Etc/rc. d/RC. sysinit: starts system service programs, such as system environment variable settings, system clock settings, loading fonts, checking and loading file systems, and generating system startup information logs.

Sysinit: the system starts and executes the commands in process. No matter which running level, the service starts as long as the system starts.

 

Appendix-if you want a service to run automatically at any running level, you can write it to/etc/rc. d/RC. in the sysinit file.

 

Statement 3:

L3: 3: Wait:/etc/rc. d/RC 3

/Etc/rc. d/RC

 

Purpose: based on the previous article, determine the default running level to call the/etc/rc. d/RC Script, execute the service program in the directory of the corresponding running level, and complete the initialization settings for the corresponding running level.

 

Linux service storage directory:/etc/rc. d/RC [0123456]. d

 

Store the soft symbolic links corresponding to the running-level service program scripts, and link them to the corresponding scripts in the init. d directory.

S-start: these services are loaded in sequence at system startup.

K-kill: Shut down these services in turn when the system shuts down [if the file name is changed, it will not start]

Number: indicates the startup sequence. The smaller the number, the higher the priority.

 

 

Appendix-if you do not want to start this service, you only need to rename it, for example:

MV S03-vmware-tools s03-vmware-tools # not automatically started

 

Full description of the/etc/inittab File

### Indicates that the current default running level is 5 (initdefault); Id: 5: initdefault: ### automatically run/etc/rc at startup. d/RC. sysinit script (sysinit) # system initialization. si: sysinit:/etc/rc. d/RC. sysinit l0: 0: Wait:/etc/rc. d/RC 0 L1: 1: Wait:/etc/rc. d/RC 1 l2: 2: Wait:/etc/rc. d/RC 2 L3: 3: Wait:/etc/rc. d/RC 3 L4: 4: Wait:/etc/rc. d/RC 4 ### when the running level is 5, run/etc/rc with 5 as the parameter. d/RC Script. Others will be ignored. init will wait for it to return (wait) L5: 5: Wait:/etc/rc. d/RC 5 L6: 6: Wait:/etc/rc. d/RC 6 ### allow restarting the system by CTRL-ALT-DELETE during startup # trap CTRL-ALT-DELETE CA: ctrlaltdel: /sbin/shutdown-T3-R now # When our ups tells us power has failed, assume we have a few minutes # of power left. schedule a shutdown for 2 minutes from now. # This does, of course, assume you have powerd installed and your # ups connected and working correctly. PF: powerfail:/sbin/shutdown-f-h + 2 "power failure; system shutting down" # If power was restored before the shutdown kicked in, cancel it. PR: 12345: powerokwait:/sbin/shutdown-c "power restored; shutdown cancelled "### run the/sbin/mingetty program with ttyx as the parameter at levels 2, 3, 4, and 5, and open the ttyx terminal for user login, if the process exits, run the mingetty Program (respawn) # Run Gettys in standard runlevels 1: 2345: respawn:/sbin/mingetty tty1 2: 2345: respawn: /sbin/mingetty tty2 3: 2345: respawn:/sbin/mingetty tty3 4: 2345: respawn:/sbin/mingetty tty4 5: 2345: Weight:/sbin/mingetty tty6: 2345: respawn:/sbin/mingetty tty6 ### run the xdm program at level 5, provide the xdm graphical logon interface, and re-execute the code upon exit (respawn) # Run xdm in runlevel 5 X: 5: respawn:/etc/X11/preofdm-nodaemon


System-related scripts, commands, and logs

1./etc/rc. d/init. d

This directory stores the startup scripts of various running levels. In this way, we can manually start/close any service in the system [with/etc/init. d/The Directory works the same in centos 5. /etc/init. D is just a connection file]

 

For example, manually start ssh/etc/rc. d/init. d/sshd # prompt option Information

 


2. dmesg: view all startup information and check whether the hardware is recognized by the kernel.

Dmesg | grep eth0 // view the load information

Dmesg | grep SDA // view the loading information of the first hard disk

 

3. All directory files of the system are saved in the/var/log directory.

 

Check the system log/var/log/messages to find the application errors that may be ignored by dmesg!

 



Set the program to start automatically

Method 1. Generate a soft link ln-S

For example, write the script/etc/rc. d/init. d/msg. Sh.

data >> /root/msg.todaywho >> /root/msg.todayfree >> /root/msg.today

Chmod U + x/etc/rc. d/init. d/msg. Sh

Ln-S/etc/rc. d/init. d/msg. sh/etc/rc. d/rc3.d/s100msg. Sh

 

 



Method 2. chkconfig: only services installed by default can be changed.

Chkconfig -- list # view all startup programs in the default state of all running levels

Chkconfig -- list sshd # Only displays the sshd startup status

Chkconfig -- levels 2345 sshd off

 

Other chkconfig options

 



Method 3: ntsysv

If ntsysv is hit, the startup setting of the current running level is changed.

 

Other running levels: ntsysv -- levels 3

[Relatively simple and intuitive, but many UNIX systems do not have this Service]

 


Common Values of action:

1. initdefault, sysinit

2. Wait: Execute the specified command in process and wait until it ends before running other commands.

Once: Execute the specified command in process without waiting for it to end

3. ctrlaltdel: Press CTRL + ALT + DEL to specify the process

4. respawn: 1. If the command specified by process is terminated, run the command again.

5. powerfail: When a power error occurs, run the command specified by process without waiting for it to end.

Powerokwait: Execute the command specified by process when the power supply is restored


Linux Startup Process Overview

 

Inittab file profiling [centos 5.x] (version 2)

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.