Linux study note _ 5_Linux Boot Process Analysis _ 2_inittab File Analysis and System Startup Process Analysis

Source: Internet
Author: User
Tags dmesg

Inittab file profiling

[Inittab file format]: id: runlevels: action: process

[Filter out rows starting with #: grep-v "^ #"/etc/inittab | more]

Id: identifier, which is unique and can contain two digits or letters.

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

Action: Specifies the running status

Process: Specifies the script or command to run.

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 the system service program, such as setting the system clock in the system environment variable, loading the font, checking the file system, and generating the system startup information log... [Shell script, run at once boot time]

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

Statement 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.

Statement 4:/etc/rc. d/rc [0123456]. d // [/etc/rcN. d In Ubuntu]

Stores soft symbolic links corresponding to running-level service program scripts,

Link to the script 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 startup priority.

Script Name: for example, vmware

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

Rm S03-vmware-tools s03-vmware-tools // It does not start automatically

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

/Etc/rc. d/init. d [in Ubuntu:/etc/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.

For example, manually start ssh/Etc/rc. d/init. d/sshd# Prompt options

# In Ubuntu:/etc/init. d/ssh

Set the self-starting program:

Method 1: generate a soft link ln-s

For example, write a script program vim/etc/rc. d/init. d/msg. sh.

Data>/root/msg. today

Who>/root/msg. today

Free>/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/rc4.d/S100msg. sh // generate soft link

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

Directly hitting chkconfig will list its usage. The usage is very intuitive and simple and requires installation!

Chkconfig -- list lists all service programs in the default state at each running level.

Chkconfig -- list sshd only displays the sshd startup status

...

Method 3: ntsysv

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

Other running levels: ntsysv -- levels 3

Simple and intuitive. installation is required! [Many UNIX systems do not have this service]

Command-related applications:

1. 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

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

Linux Startup Process Overview:

Firmware [CMOS/BIOS] -- POST home appliance self-check [software/hardware clock synchronization, NTP]

|

BootLoader [GRUB] [in Windows: NTLDR]: load the kernel

|Root --/boot

|Kernel

|Initrd

|

Kernel? Hardware

| Init PID = 1 [parent-child process relationship]

|

/Etc/inittabFile Format id: runlevels: action: process

|

Default running level of the initdefault system: 1. single-user mode [security mode ]...

|

/Etc/rc. d/rc. sysinit: system initialization, regardless of the running level, will run this file

|

/Etc/rc. d/rc

|

/Etc/rc. d/rcN. d N = 0 ~ 6 S-start K-kill

|

Username:

PassWd:

[Also: Be sure to develop the habit of using help !]

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.