Linux Course notes DAY01 homework Summary after class

Source: Internet
Author: User

1. Linux startup Process Analysis

The boot process for the Linnux system is as follows:

    1. Load BIOS hardware information and self-test, and obtain the first bootable device according to the setup;
    2. Read and execute the boot loader (i.e. grub, spfdisk, etc.) of the MBR in the first boot device;
    3. Loading kernel,kernel based on boot loader settings will start detecting hardware and loading drivers;
    4. After the hardware driver succeeds, kernel will invoke the INIT process actively, and Init will get the run level information;
    5. Init executes/etc/rc.d/rc.sysinit to prepare the operating environment for software execution (e.g. network, time zone, etc.);
    6. Init executes the start of each service of the Run–level (script mode);
    7. Init executes the/etc/rc.d/rc.local file;
    8. Init executes the terminal emulator Mingetty to start the login process, and finally the user logs in.

BIOS , boot self test with MBR

(1) Start the entire system to let the system load the BIOS, and through the BIOS program to load the CMOS information, and through the CMOS setting value to obtain the host hardware configuration, such as CPU, the I/O address of each device, etc.

(2) After obtaining this information, the BIOS also performs power-on detection, then initializes the hardware, then defines the sequence of bootable devices.

(3) due to different operating systems, the file format is different, so different boot loader are required to load the kernel. The BIOS first reads the first sector of the first boot device detected by the hardware's INT 13 interrupt function (which is the feature supported by the hardware itself) and then executes the boot loader

Note: If the host has two hard disks, there are two mbr. Which MBR to read first, determines the BIOS settings, which drive will be set to the first boot device.

Boot Loader the function

(1) Menu available: User can choose different startup options

(2) Load kernel file: Point directly to the bootable program section to start the operating system

(3) Transfer other loader: Transfer the bootloader function to other loader responsible for

Note: Windows loader does not have control transfer by default. Each operating system defaults to a boot sector (boot sector) that installs a boot loader to the file system on which its own root directory resides. Linux when installing, you can choose to install the boot loader to the MBR, or do not install. However, Windows theoretically installs a boot loader on both the MBR and boot sector. When installing a multi-system, installing Linux after installing windows,windows will overwrite the boot loader of Linux, not the menu option of Linux, so installing multi-system installs Windows first and then installs Linux.

Load kernel detects hardware and INITRD functions

(1) Boot loader begins to read the kernel file, Linux will unzip the kernel into memory, and take advantage of the kernel functions, to start testing and driving the various peripherals, including storage devices and CPUs, network cards, sound cards and so on. The kernel file is placed in/boot and named/boot/vmlinuz.

(2) Linux is loaded by loading the dynamic module in the root directory/lib/momdules to provide load driver functions, such as the identification of USB, SATA, SCSI and other disk devices (/lib can not be placed in separate partitions)

(3) Virtual file system: The general use of file name/BOOT/INITRD, the file is also through the boot loader loaded into memory, is decompressed and emulated in memory as a root directory, and provides an executable program, through the program to load the boot process required by the dynamic module. To solve the problem that the kernel does not recognize SATA and other disks, cannot mount the root directory, and cannot load/lib/modules dynamic modules to identify SATA and other disks .

(4) Initrd to the root directory, after the kernel load the appropriate driver, the virtual file system will be released and mount the actual root file system.

Note: If the Linux system is installed on a disk in the IDE interface, and the default Ext2/ext3 file system is used, no initrd is required to enter the system, USB, SATA, and SCSI require INITRD.

First process init and configuration file/etc/inittab

The first process that the kernel actively calls is/sbin/init,pid 1, configuration file is/etc/inittab, the main function is to prepare the software star environment, including the system host name, network settings, language processing file system format, etc.

The process of init is processed from top to bottom according to the contents of the/etc/inittab file, as follows:

(1) Get runlevel First, assuming that the run level is 5

(2) using/ec/rc.d/rc.sysinit for system initialization

(3) As Run level is 5, only "5:5:WAIT:/ETC/RC.D/RC5"

(4) Set up [Ctrl]+[alt]+[del] This group of key combination function

(5) Setting up the PF,PR two mechanisms of the continuous electric system

(6) Start the Mingetty 6 terminals

(7) Finally start the graphical interface with/etc/x11/perfdm-nodaemon

Init system Initialization process (/ETC/RC.D/RC.SYSINIT)

different distributions of Linux will have different script names, whichever is defined in/etc/inittab

/etc/rc.d/rc.sysinit's main work is about the following:

(1) Access to network environment and host type

(2) test and Mount memory device/proc and USB settings/sys

(3) Decide whether to start SELinux

(4) Start the system random number generator (Help the system to carry out the function of some cryptographic calculus)

(5) Setting the terminal font

(6) Set the Welcome screen to display during startup

(7) Set the system time and time zone setting: Read into the/etc/sysconfig/clock setting value

(8) Detection of interface devices and testing of Plug and Play (PnP) parameters

(9) User-defined module loading: Users can add custom modules to the/etc/sysconfig/modules/*.modules

(10) Load the relevant settings of the kernel: the system will take the initiative to read/etc/sysctl.conf this file setting value

(11) Setting the hostname and initializing the Power management module

(12) Initialize the software disk array: Mainly/etc/mdadm.conf to set up a good

(13) Initialization of LVM file system functions

(14) Checking the disk file system with FSCK, filesystem check

(15) Conversion of disk quota quota

(16) Re-mount the system CD in read-write mode

(17) Start Quota function

(18) Startup system is a random number generator

(19) Clear the temporary files during startup

(20) Load the relevant information into the/VAR/LOG/DMESG

start the system service with the associated startup configuration file

(1) through the external first parameter ($) to get the script directory you want to execute, that is,/ETC/RC.D/RC X can get/etc/rcx.d this directory to prepare to process the relevant script

(2) Find/etc/rcx.d/k?? * Start the file and proceed to/etc/rcx.d/k?? Operation of the *stop

(3) Find/etc/rcx.d/s?? * Start the file and proceed to/etc/rcx.d/s?? Operation of the *start

Note:/etc/rcx.d/[sk]xx is actually running to/etc/init.d/to find the corresponding service script, then start or stop respectively. (xx is the order of execution)

User-defined boot loader (etc/rc.d/rc.local)

User-defined shell script does not need to be placed inside the/ETC/INIT.D, just write the full file name of the shell script/etc/rc.d/rc.local

2. /etc/inittab file and run level 0-6 summary

After Linux boot loads the core, the system is ready to wait for the program to execute. The first program to start is "/sbin/init".

The Init program works quite a lot, and in addition to using the profile "/etc/inittab" to get the run level, it also launches different service items through a run-level setting. Depending on whether there is a network with or without X window,linux boot is divided into 6 operating levels, respectively

The 0‐halt system shuts down directly.

The 1‐single user mode is used to maintain the system in the event of a problem.

The 2‐MULTI‐USER,WITHOUTNFS is similar to Level 3 but has no NFS service.

3‐full Multi‐user mode is a complete text-only pattern with network functionality.

4‐unused system retention function.

5‐X11 is similar to Level 3, but with X Window.

6‐reboot restart

Contents of File/etc/inittab

#设置熊启动的运行等级设置项目

Id:3:initdefault:

#开始启动运行等级的服务前, use the setup file to detect and initialize the system environment:

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

#7 a five-blessing script placement path that needs to be started for different levels of operation:

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

L5:5:WAIT:/ETC/RC.D/RC 5

L0:6:WAIT:/ETC/RC.D/RC 6

#是否允许按下 [Ctrl]+[alt]+[del] To restart the Setup project:

CA::CTRLALTDEL:/SHIN/SHUTDOWN‐T3 one R now

#本机终端启动的个数:

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:respawn:/sbin/mingetty Tty5

6:2345:respawn:/sbin/mingetty Tty6

#在 X Window (Run Level 5) in the context of the Startup script Setup project:

X:5:once:/etc/x11/prefdm‐nodaemon

The syntax for this file is this:

[Set the action behavior of the project ":[run level]:[init]:[Command Project]

1. Set up the project:

A maximum of 4 characters, representing the primary work item of INIT, is simply a description of the presentation.

2. Operating level:

Which run level of the project is executed. A 35 indicates that run level 3 and 5 will be executed.

3.init of operation items:

The significance of the main project is as follows:

Initdefault: Represents the recognized run level setting value.

Sysinit: Represents the system initialization action item.

Ctrlaltdel: Indicates that [Ctrl]+[alt]+[del] three can be restarted by the setting.

Wait: Indicates that the following command item must be completed before the subsequent operation can continue.

Respawn: Indicates that the subsequent INIT will still be actively "restarted".

Based on file analysis

If we do not want the user to use [Ctrl]+[alt]+[del] to restart the system, we can comment out:

CA::CTRLALTDEL:/SHIN/SHUTDOWN‐T3 one R now

If we want to set the default operating level of the system boot we can modify the Id:3:initdefault: number.

Common shortcut keys under 3.linux

Shortcut key: Ctrl+alt+del

Function: Turn off the computer

Note:

Shortcut key: Alt+fn (F1,f2,f3 ...)

Function: Switch to nth console

Note:

1. By default, Linux provides us with 6 terminals, or console interface F7.

2. The cached content will also be erased after switching the console.

Shortcut key: Scroll Lock

Function: When the screen output scrolling too fast, you can use this button to hold the screen, and then press unlock.

Note:

1. When the screen is locked, it just doesn't seem to react, but the input system is still being processed, but you can't see it.

2. If your console appears inexplicable unresponsive, like the crash, you can try to create a screen lock because of accidentally triggered.

Shortcut keys: Shift+pageup or Shift+pagedown

Function: Scroll the console cache up and down.

Note:

Shortcut key: Ctrl+l

Function: Clear screen, equivalent to clear

Note:

Shortcut keys: Ctrl + C or ctrl+\

Function: Kill or say end the current task

Note:

Shortcut key: Ctrl+d

Function: The function is EOF that is the end of the file (End‐of‐file).

Note:

Shortcut key: Ctrl + Z

Role: End Process

Note:

Shortcut key: Ctrl + A

Action: Move the cursor to the beginning of the command line.

Note:

Shortcut key: Ctrl+e

Action: Move the cursor to the end of the command line.

Note:

Shortcut key: Ctrl+u

Function: Clears all characters in the command line before the cursor is in place.

Note:

Shortcut key: Ctrl+w

Function: Clears the left field

Note:

Shortcut key: Ctrl+y

Effect: will be affixed to the ctrl+u or ctrl+k or ctrl+w clear parts

Note:

Shortcut key: Ctrl+r

Function: Automatically searches the command cache for subsequent characters that are entered.

Note:

Shortcut keys: Tab

Function: Command line auto-complete

Note:

Shortcut key: Ctrl+k

Function: Clears the character from the location of the prompt to the end of the line.

Linux Course notes DAY01 homework Summary after class

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.