Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the startup process of Linux system?

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about the startup process of the Linux system, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

Part III: system initialization

There is a line in the configuration file of init:

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

It calls to execute / etc/rc.d/rc.sysinit, and rc.sysinit is a bash

Shell script, it is mainly to complete some system initialization work, rc.sysinit is every run level must first run the important script. Its main tasks are as follows: activate the exchange points.

Zone, check disks, load hardware modules, and other priority tasks.

Rc.sysinit has more than 850 lines, but each single function is relatively simple and annotated. It is recommended that interested users can read the file on their own machines to learn more about the initialization of the system. Because this file is long, it is not listed in this article, nor is it introduced in detail.

When the rc.sysinit program is finished, it will return to init to continue to the next step.

Part IV: start the daemon process corresponding to the running level

After the rc.sysinit is executed, the init is returned to continue the other actions, usually followed by the / etc/rc.d/rc program. Taking runlevel 3 as an example, init executes the following line in the configuration file inittab:

L5:5:wait:/etc/rc.d/rc 5

This line indicates that running / etc/rc.d/rc,/etc/rc.d/rc with 5 as an argument is a Shell script that takes 5 as an argument to execute / etc/rc.d

All the rc startup scripts in the / rc5.d/ directory, and the startup scripts in the / etc/rc.d/rc5.d/ directory are actually link files, not real rc startup scripts

The real rc startup scripts are actually placed in the / etc/rc.d/init.d/ directory. These rc startup scripts have a similar usage, they can generally accept start, stop,

Parameters such as restart, status, etc.

The rc startup script in / etc/rc.d/rc5.d/ is usually a linked file that begins with K or S, and for files that start with S

And will be run with the start parameter And if you find that there is a corresponding script, there is also a link that starts with K, and it is already in the running state (under / var/lock/subsys/

File as a flag), these started daemons will be stopped first with stop as the parameter, and then rerun. This is done to ensure that when init changes the runlevel, all relevant daemons

Processes will be restarted.

As to which daemons will run in each runlevel, users can set their own through the "System Services" in chkconfig or setup. Common daemons are:

Amd: automatically install the NFS daemon

Apmd: advanced power management daemon

Arpwatch: log and build a database of Ethernet address and IP address pairs seen on the LAN interface

Autofs: automatically installs the management process automount, related to NFS, dependent on NIS

Daemon for scheduled tasks under crond:Linux

Named:DNS server

Netfs: installing NFS, Samba, and NetWare network file systems

Network: activate a script that has a configured network interface

Nfs: open the NFS service

Portmap:RPC portmap Manager, which manages connections based on RPC services

Sendmail: Mail server sendmail

Smb:Samba file sharing / printing service

Syslog: a script that lets the system boot up the syslog and klogd Syslog waiting processes

Xfs:X Window font server, which provides font sets for local and remote X servers

Xinetd: a core daemon that supports a variety of network services, and can manage wuftp, sshd, telnet and other services

After these daemons are started, the rc program is finished, and then you will return to init to proceed to the next step.

Part V: establishing a terminal

When the execution of rc is finished, return init. At this point, the basic system environment has been set up, and various daemons have been started. Init then opens six terminals so that users can log in to the system. You can switch among the six terminals by pressing Alt+Fn (n corresponds to 1-6). The following six lines in inittab define six terminals:

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

From the above, we can see that the mingetty program will be run in respawn mode in the run levels of 2, 3, 4 and 5, and the mingetty program can open the terminal and set the mode. At the same time, it will

Displays a text login interface, which is the login interface we often see, in which the user is prompted for a user name, and the user entered by the user will be passed as a parameter to the login program for verification

Verify the identity of the user.

Part VI: log in to the system, start up and complete

For graphical users running level 5, their login is through a graphical login interface. After logging in successfully, you can go directly to KDE, Gnome and other window managers. This article is mainly about the situation of text login:

When we see the login screen of mingetty, we can enter the user name and password to log in to the system.

Linux's account verifier is that login,login accepts the user name from mingetty as the user name parameter. Login then analyzes the user name: if the user name

Not root, and the / etc/nologin file exists, login will output the contents of the nologin file and then exit. This is usually used to prevent non-root users from logging in during system maintenance.

Record. Only terminals registered in / etc/securetty allow root users to log in, and if this file does not exist, root can log in on any terminal. / etc

The / usertty file is used to impose additional access restrictions on users, and if this file does not exist, there are no other restrictions.

After analyzing the user name, login will search / etc/passwd and / etc/shadow to verify the password and other information about the account, such as what the home directory is and what shell to use. If no home directory is specified, it defaults to the root directory; if no shell is specified, it defaults to / bin/bash.

After the login program succeeds, it outputs the last login information (recorded in / var/log/lastlog) to the corresponding terminal, and checks whether the user has any new mail (in / usr).

/ spool/mail/ under the corresponding user name directory). Then start setting various environment variables: for bash, the system first looks for the / etc/profile script file and executes

It; then if the .bash _ profile file exists in the user's home directory, it is executed, in which other configuration files may be called, and after all the configuration files are executed, the various environments change

When the quantity is set, the familiar command prompt will appear, and the whole startup process will be over.

After reading the above, do you have any further understanding of the startup process of the Linux system? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report