Link: http://blog.sina.com.cn/s/blog_4b065e2a01013dp3.html
/Etc/profile:This file sets the environment information for each user in the system. When the user logs on for the first time, the file is executed and shell settings are collected from the configuration file in the/etc/profile. d directory.
/Etc/bashrc:Execute this file for every user running bash shell. When bash shell is opened, the file is read.
~ /. Bash_profile:Each user can use this file to input the shell information dedicated to his own use. When a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. BashrcFile.
~ /. Bashrc:This file contains bash information dedicated to your bash shell. When you log on and each time you open a new shell, this file is read .(Each user has a. bashrc file in the user directory.)
~ /. Bash_logout:Execute this file every time you exit the system (exit bash shell.
In addition, the variables (global) set in/etc/profile can act on any user ~ /. BashrcThe variables (local) set in/etc/profile can only inherit the variables in/etc/profile. They are "Parent-Child" relationships.
~ /. Bash_profile is interactive and login to run in bash.
~ /. BashrcIs used to run bash in interactive non-login mode.
Generally, the two settings are roughly the same, so the former usually calls the latter.
The file execution process when logging on to Linux is as follows:
When logging on to Linux, start the/etc/profile file first, and then start ~ /. Bash_profile ,~ /. Bash_login or ~ /One Of The. profile files,
The execution sequence is :~ /. Bash_profile ,~ /. Bash_login ,~ /. Profile.
If ~ /. If the bash_profile file exists, it is generally executed ~ /. Bashrc file.
Because in ~ The/. bash_profile file usually contains the followingCode:
If [-f ~ /. Bashrc]; then
../Bashrc
Fi
~ /. Bashrc usually has the following code:
If [-F/etc/bashrc]; then
./Bashrc
Fi
So ,~ /. Bashrc calls the/etc/bashrc file. Finally, when you exit the shell, ~ /. Bash_logout file.
The execution sequence is:/etc/profile-> (~ /. Bash_profile | ~ /. Bash_login | ~ /. Profile)-> ~ /. Bashrc->/etc/bashrc-> ~ /. Bash_logout
The scope of each file is described as follows:
(1)/etc/profile: This file sets the environment information for each user in the system. When the user logs on for the first time, this file is executed. and from/etc/profile. d directory configuration file to collect shell settings.
(2)/etc/bashrc: execute this file for every user running bash shell. When bash shell is opened, the file is read.
(3)~ /. Bash_profile:Each user can use this file to input the shell information dedicated to his own use. When a user logs on, this file is only executed once! By default, it sets some environment variables to execute the user's. bashrc file.
(4)~ /. Bashrc:This file contains bash information dedicated to your bash shell. This file is read when you log on and each time you open a new shell.
(5 )~ /. Bash_logout: execute this file every time you exit the system (exit bash shell). In addition, the variable (global) set in/etc/profile can act on any user, and ~ The variables (local) set in/. bashrc can only inherit the variables in/etc/profile. They are "Parent-Child" relationships.
(6 )~ /. Bash_profile is interactive and login to run bash ~ /. Bashrc is the interactive non-login mode that enters Bash. Generally, the two settings are roughly the same, so the former usually calls the latter.