SHELL script strategy (learning notes) -- 1.5 bash environment configuration process, -- 1.5 bash
From the perspective of user login, shell is divided into two types:
Logon shell: If you log on through a terminal, use the su-username command to switch users.
Non-interactive shell: for example, you can use the su username command to switch between users. Open the command terminal and shell script in the graphic terminal.
A simpler but inaccurate differentiation method is: non-interactive shells that do not need to enter the account and password to log on, such as subshells, script shells, and command windows opened in graphic terminals, except for su username.
Bash environment configuration file:
Global configuration:/etc/profile,/etc/profile. d/*. sh,/etc/bashrc.
Personal Configuration :~ /. Bash_profile ,~ /. Bashrc.
The read and execute environment configuration files are sequential. If the settings conflict, the configuration files read later overwrite those read first.
Procedure for reading the configuration file:
The log-on shell reads the environment configuration files in the following sequence:
(1)/etc/profile -->/etc/profile. d/*. sh
(2 )~ /. Bash_profile --> ~ /. Bashrc -->/etc/bashrc
Read the global configuration file/etc/profile before reading the user configuration file ~ /. Bash_profile. However, the/etc/profile file will call all. sh files in the/etc/profile. d/directory ,~ /. Bash_profile will call ~ /. Bashrc file ,~ /. Bashrc will call the/etc/bashrc file again. In fact,/etc/bashrc will also call/etc/profile. d/*. sh, but it will not repeat the set options.
The order in which non-Logon shell reads environment configuration files is:
~/.bashrc-->/etc/bashrc-->/etc/profile.d/*.sh
That is to say:
/Etc/profile: read when any user logs in. Non-Logon shell does not read data.
~ /. Bash_profile: it is read when the user logs on to configure the bash shell to be opened. Non-Logon shell does not read data.
~ /. Bashrc: For the bash shell configuration, the corresponding user will read the file every time he opens a shell, because the login or non-login shell will read the file.
/Etc/bashrc: (all users) the file is read every time a shell is opened (login or non-login.
Back to series article outline: http://www.cnblogs.com/f-ck-need-u/p/7048359.html
Reprinted please indicate the source: http://www.cnblogs.com/f-ck-need-u/p/7229025.html