2015-01-0810:49:29
About logging in to Linux,/etc/profile, ~/.bash_profile, and so on several files of the execution process.
The procedure to execute a file when logging on to Linux is as follows:
When you first log in to Linux, start the/etc/profile file, and then start one of the ~/.bash_profile, ~/.bash_login, or ~/.profile files in the user directory, in the following order: ~/.bash_ Profile, ~/.bash_login, ~/.profile. If the ~/.bash_profile file exists, the ~/.BASHRC file is typically executed. Because the following code is commonly found in the ~/.bash_profile file:
If [-f ~/.BASHRC]; Then
. ./BASHRC
Fi
In ~/.BASHRC, the following code is generally available:
if [-F/ETC/BASHRC]; Then
. /bashrc
Fi
Therefore, ~/.BASHRC will call the/ETC/BASHRC file. Finally, when you exit the shell, the ~/.bash_logout file is also executed.
Order of execution:/etc/profile---(~/.bash_profile | ~/.bash_login | ~/.profile), ~/.BASHRC,/ETC/BASHRC, ~/.bash_lo Gout
For the scope of each file, the following instructions were found on the Web:
(1)/etc/profile: This file sets the environment information for each user of the system, and the file is executed when the user logs on for the first time. and collect the shell settings from the configuration file of the/ETC/PROFILE.D directory.
(2)/ETC/BASHRC: Executes this file for each user running the bash shell. When the bash shell is opened, the file is read.
(3) ~/.bash_profile: Each user can use this file to enter the shell information dedicated to their own use, when the user log on, the file is only executed once! By default, he sets some environment variables to execute the user's. bashrc file.
(4) ~/.BASHRC: This file contains bash information dedicated to your bash shell, which is read when you log in and every time you open a new shell.
(5) ~/.bash_logout: Executes the file each time it exits the system (exiting the bash shell). In addition, the variables set in/etc/profile (global) can be applied to any user, while the variables set in ~/.BASHRC, etc. (local) only inherit variables from/etc/profile, they are "parent-child" relationships.
(6) ~/.bash_profile is the interactive, login way into bash run ~/.BASHRC is the interactive non-login way into bash normally the two settings are roughly the same, so the former usually calls the latter.
Implementation of/etc/profile, ~/.bash_profile ~/.profile under Linux