Java EE Development of various types of resources download list, the history of the most complete IT resources, personal collection summary.
The process of executing files when you log on to Linux is as follows:
When you just log on to Linux, start the/etc/profile file first, and then start one of the ~/.bash_profile, ~/.bash_login, or ~/.profile files in the user directory.
The order of execution is: ~/.bash_profile, ~/.bash_login, ~/.profile.
If the ~/.bash_profile file exists, the ~/.BASHRC file is usually executed.
Because the following code is generally available in the ~/.bash_profile file:
If [f ~/.BASHRC]; Then
. ./BASHRC
Fi
In ~/.BASHRC, the following code is generally available:
if [-F/ETC/BASHRC]; Then
. /etc/bashrc
Fi
Therefore, ~/.BASHRC will invoke the/ETC/BASHRC file. Finally, when you exit the shell, the ~/.bash_logout file is also executed.
The order of execution is:/etc/profile-> (~/.bash_profile | ~/.bash_login | ~/.profile)-> ~/.BASHRC->/ETC/BASHRC-> Ogout
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 the first time the user logs on. and collects the shell's settings from the/ETC/PROFILE.D directory's configuration file.
(2)/ETC/BASHRC:Execute this file for each user running the bash shell. When the bash shell is opened, the file is read (that is, every time a new terminal is opened, the BASHRC is executed).
(3)~/.bash_profile:Each user can use this file to enter shell information that is specific to their own use, and that file is executed only once when the user logs on. By default, some environment variables are set to execute the user's. bashrc file.
(4)~/.BASHRC:The file contains bash information dedicated to your bash shell, which is read when you log in and each time you open a new shell.
(5)~/.bash_logout:Executes the file every time you exit the system (the Bash shell is exited). In addition, the variables set in the/etc/profile (global) can be applied to any user, while the variables set in ~/.BASHRC, such as local, can only inherit the variables in/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 usually the two settings are basically the same, so usually the former will call the latter.
the use of various environment variable settings files such as/etc/profile and/etc/environment
1) First will export LANG=ZH_CN to join/etc/profile, exit the system to log in, Login prompts display in English.
2) First will/etc/profile in the export LANG=ZH_CN Delete, will LNAG=ZH_CN joins/etc/environment, exits the system to log in again, the login prompt displays the Chinese.
The user environment is set up to always execute/etc/profile before reading/etc/environment. Why is it so different from what we've been describing? Instead of executing/etc/environment first, then executing/etc/profile.
This is because:/etc/environment is the environment in which the entire system is set up, and/etc/profile is setting up all users ' environments, which are not related to logged-in users, but to logged-in users.
The execution of a system application can be irrelevant to the user environment, but is relevant to the system environment, so when you log in, the prompt that you see, such as date and time information, is related to the system environment Lang, default Lang=en_us, if the system environment LANG=ZH_CN, The message is in Chinese, otherwise it is in English.
For the user's shell initialization, the/etc/profile is executed first, the file/etc/environment is read, and the/etc/environment is executed first for the entire system. Is that a good idea?
The order to log in to the system should be
/etc/enviroment-->/etc/profile--> $HOME/.profile--> $HOME/.env (if present)
/etc/profile is the environment variable for all users
/etc/enviroment is the environment variable of the system
When you log in to the system, the shell should read the sequence
/etc/profile->/etc/enviroment--> $HOME/.profile--> $HOME/.env
The reason should be the difference between the user environment and the system environment, if the same variable in the user environment (/etc/profile) and the system environment (/etc/environment) have different values, it should be based on the user environment.
Development Reference:
Linux environment variables
Bash again shell startup file
Ubuntu's ADB environment variable configuration