/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 starts from/etc/profile. the configuration file in the d directory Collects shell settings.
/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 their 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 .~ /. Bash_login: if Bash is executed in the login mode, read ~ /. Bash_profile. If it does not exist, read ~ /. Bash_login. If the first two do not exist, read ~ /. Profile .~ /. Profile: if Bash is executed in the login mode, read ~ /. Bash_profile. If it does not exist, read ~ /. Bash_login. If the first two do not exist, read ~ /. Profile. In addition, this file will be read when logging on in graphic mode, even if ~ /. Bash_profile and ~ /. Bash_l ~ /. Bashrc: This file contains bash information dedicated to your bash shell. This file is read when you log on and every time you open a new shell.
~ /. Bash_logout: execute this file each time you exit the system (exit bash shell. that is to say, when you log out in text mode, the file will be read, and when you log out in graphic mode, the file will not be read.
The following are some examples on the local machine: 1. When logging on to the graph mode, read:/etc/profile and ~ sequentially ~ /. Profile
2. After logging on to the terminal in graphic mode, read:/etc/bashrc and ~ /. Bashrc
3. When logging on in text mode, read:/etc/bashrc,/etc/profile ,~ /. Bash_profile and ~ /. Bashrc
4. Su from another user to this user is divided into two situations:
(1) If the-l parameter (or-parameter, -- login parameter) is included, for example, Su-l username, bash is lonin and it reads the following configuration files in sequence: /etc/bashrc,/etc/profile ~ /. Bash_profile and ~ /. Bashrc.
(2) If the-l parameter is not included, bash is non-login, which reads:/etc/bashrc and ~ sequentially ~ /. Bashrc
5. When logging out, or logging out of the su user, if it is in Longin mode, Bash will read :~ /. Bash_logout
6. When executing a custom shell file, if the "bash-l a. Sh" method is used, Bash will read the line:/etc/profile ,~ /. Bash_profile ,~ /. Bashrc and/etc/bashrc. If other methods are used, such as Bash. sh ,. /. sh, sh. sh (this does not belong to bash shell), it will not read any of the above files.
7. In the above example ~ /. Bash_profile. If the file does not exist, read ~ /. Bash_login. If the first two do not exist, read ~ /. Profile.
Differences between bashrc and Profile
To understand the differences between bashrc and profile, first understand what is interactive shell and non-interactive shell, What Is Login Shell and non-login shell.
In interactive mode, shell waits for your input and runs the command you submit. This mode is called interactive because shell interacts with users. This mode is also very familiar to most users: logon, command execution, and logout. When you sign back, shell is terminated. Shell can also run in another mode: non-interactive mode. In this mode, shell does not interact with you, But reads commands stored in files and runs them. When it reads the end of the file, shell is terminated.
Both bashrc and profile are used to save the user's Environment Information. bashrc is used for interactive non-loginshell, while profile is used for interactive login shell. Many bashrc and profile files exist in the system. The following describes them one by one:
Etc/profile/etc/bashrc ~ /. Bash_profile ~ /. Bashrc and other configuration file differences