The following describes the startup process and logon methods in Linux, including BIOS startup, GRUB system loading, and system startup files. There are multiple logon methods, including virtual console and remote logon, for more information, see.
Linux Startup Process
1. BIOS startup
After the system is powered on, the computer first loads the BIOS from the CMOS (complementary Metal Oxide Semiconductor) chip and checks the basic information of the system hardware, such as memory, hard disk, and processor. Then, the BIOS looks for whether there is a system Boot disk. If not, the system looks for the Master Boot Record in the MBR (Master Boot Record) and runs the program recorded on the MBR. Generally, this program is the Loader program of the Operating System (BootLoader in the embedded system). Its main function is to indicate the system to be loaded and the loading method after the system is started. For example, after running the Linux Loader Program (GRUB and LILO) on the MBR, you can load the Linux kernel.
BIOS is called firmware. In computer systems, BIOS programs are stored in the motherboard chip. formatting the hard disk has no effect on this information. Besides using a dedicated tool to erase the information, the content of the hard disk always exists.
2. GRUB Loading System
GRUB is a system-running Loader. Generally, after the Linux operating system is installed, GRUB is the first program to start the system.
This program is used to load the operating system kernel (if there are multiple operating systems, this program can be used to choose to start multiple operating systems ).
In Linux, the startup-related applications are located in the/boot folder. The application read when GRUB is run is/boot/grub. conf file. modify this file to set the boot wait time for loading the Operating System (after the wait time is exceeded, the system will start the default boot operating system), boot menu, default operating system and operating system kernel image file and location.
# Ls-l/boot/grub. conf // check the file location
# Cat/boot/grub. conf // display the content of this file
3. System Startup File
After the Linux kernel is loaded, the system runs the following kernel programs in sequence. The 1st kernel files run by the system are/sbin/init. This program creates 1st processes in the system and uses this process as the parent process of the application after the system, then run/etc/rc. d/rc. sysinit initializes the system. /Etc/inittab is the 3rd important program run by the system. This program is mainly used to select the system startup level and run different programs and commands at different startup levels, these files are stored in/etc/rcX. d folder. After the preceding content is executed, the system loads the user-specific information. These files are described in detail below.
(1)/sbin/init. This file is located in the/sbin folder. You can query the current system process at the # prompt and find that the init process number is
0. The process must be active throughout the system unless the system is disabled.
# Ls/sbin/init // view the location of the init file
# Ps-aux // view all processes in the current system
(2) After the/etc/rc. d/rc. sysinit. process 0 is created, the system will read the file/etc/rc. d/rc. sysinit for system initialization.
The system initialization content includes the following aspects:
Set the environment variable content;
Read/etc/sysconfig/network;
Use fsck to detect the file system;
Store the startup information in/var/log/dmesg through dmesy;
Use the/etc/sysconfig/clock file to initialize clock;
Detect System Parameter proc and set PNP;
Run rc. erial to initialize the serial port;
Install the root and proc file systems and other file systems;
Set the font and start Swapping.
(3)/etc/inittab. After reading and checking the basic information of the system, the system will read the/etc/inittab file and select the default running level to determine which system services to start. Linux includes six running levels. Different running levels enable different hardware and system environments by default. For example, to enable the network environment, you must enable it in level 3 and Level 5; system errors to be modified are generally performed in single-user mode Level 1. In general, the system will default the Departure Level 3 or Level 5.
# Cat/etc/inittab
The meanings of the six running levels are as follows:
0. Suspension mode. We recommend that you do not set it to this level;
1. single-user mode, generally used for system repair;
2. Multi-user mode, but not supported by the Network File System;
3. Full mode for multiple users. Many servers choose this mode;
4, not used;
5. It is in X11 mode, that is, graphical interface. You need to select this level to run the desktop system;
6. Restart mode.
(4)/etc/rcX. d. based on the default level selected in the/etc/inittab, the system reads/etc/rcX. d folder (X is the corresponding level, such as 1, 2, 3 ...), all files in this folder are prefixed with S and K.
4. initialize User Files
(1)/etc/rc. d/rc. local is a script file. After completing the above initialization, you can load the program to run when the system starts in this folder. Programs automatically started when the system starts can be added to this file, which is equivalent to a batch processing program at startup.
(2)/etc/profile file. After reading/etc/rc. d/rc. local, the system sets the environment variable, which is the most important shell configuration file of the system and the first File Detected by the system during user login. It mainly includes PATH, USER, LOGNAME, MAIL, and how.ame.
(3)/home/$ USERNAME/./bash_profile file. After reading the/etc/profile file, users will read their own unique configuration files,
All users except the root user will read the/home/$ USERNAME/. bash_profile file and set their own environment variables.
After the preceding files are executed, you can log on to the Linux operating system.
Linux logon Mode
Linux is a multi-user network operating system with multiple logon methods, including virtual console and remote logon. After Linux is started to the graphic interface (level 3), the system provides multiple virtual consoles, each of which is independent of each other and does not affect each other. On the Character interface, you can press the shortcut key Alt + F1 ~ F6 switches between multiple virtual consoles. You can use startx to switch to the graphic interface. If the current graphic interface is used, you can press the shortcut key Alt + Ctrl + F1 ~ Switch to the character virtual terminal F6, and press Alt + Ctrl + F7 to return to the graphic interface.
Remote logon is a very important logon method. Linux servers generally use remote logon to log on to the system. Usually, telnet is used.