Linux system startup process and user login process Analysis __linux

Source: Internet
Author: User
Linux system startup and user Login process analysis:

First, the system starts the process
1. Loading kernel
2. Execute INIT Program
3,/etc/rc.d/rc.sysinit? Description: The first script executed by Init
4,/etc/rc.d/rc${runlevel}d/* Description: $RUNLEVEL for the default operating mode
5,/etc/rc.d/rc.local??? Note: After the corresponding level service starts, executes the file (in fact, you can also write the commands that need to be executed into the file)
6,/sbin/mingetty Description: Waiting for users to log in

Description
(i) The execution of the/etc/rc.d/rc.sysinit is independent of the operating mode (that is, the $runlevel, including the 1,2,3,4,5,6 six levels), and performs the same initialization task:

1), into the Keymap and system fonts
2), start swapping
3), set the host name
4), set NIS domain name
5), check (fsck) and Mount file system
6), open quota
7), loading sound card module
8), set the system clock
9), other

(b) After executing the Rc.sysinit script, the system chooses the corresponding/ETC/RC.D/RCX.D according to the operation mode,
Where the operating mode reads from the "Id:3:initdefault:" position in the/etc/inittab file;
After executing the corresponding script under/ETC/RC.D/RCX.D, execute the content in the/etc/rc.local file;
The next step is to wait for the user to log on, and the user will perform a sequence of initialization scripts for the user's environment.

Second, the user login process
The scripts associated with user login are:
1), etc directory under the PROFILE,BASHRC
2), user-hosted directory of. Bash_profile,. BASHRC

(i), by adding the echo output at the beginning of each script and redirecting to the test results below/tmp/bashtest:

[Root@www ~]# Cat/tmp/bashtest
I Am/etc/profile, executed at Fri June 6 20:01:30 CST 2014.
I am. Bash_profile, executed at Fri June 6 20:01:30 CST 2014.
I am. bashrc,executed at Fri June 6 20:01:30 CST 2014.
I AM/ETC/BASHRC, executed at Fri June 6 20:01:30 CST 2014.
[Root@www ~]#

(ii) As you may know, the order in which the above scripts are executed is:/etc/bash_profile => ~/.bash_profile => ~/.BASHRC =>, and it has been tested that
The script execution under the/etc/profile.d/directory is also performed before ~/.bash_profile.

After exiting the system, use another user to log in and discover that the file that started with bash was not executed:
Thus, four documents/ETC/PROFILE,/ETC/BASHRC,~/.BASH_PROFILE,~/.BASHRC:
The first two are global, and each user login will perform
The latter two are private, set for a specific user, that is, for the user

(iii) To analyse the two documents of ~/.BASH_PROFILE,~/.BASHRC

1. Comments in the Bash_profile file:
#. Bash_profile
# get the aliases and functions

Visible:. Bash_profile role: Setting up a custom environment and starting a program

2. Comments in the BASHRC file:
#. BASHRC
# User specific aliases and functions

Visible:. BASHRC role: Set custom aliases and functions.

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.