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/pro this file sets environment information for each user in the system. When the first user logs on, this file is executed. And collect shell settings 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. Some Linux versions have no bashrc files in the/etc directory. ~ /. Pro each user can use this file to input the shell information dedicated to their own use. When a user logs on, The file is executed only once! By default, it sets some environment variables and then executes the user's. bashrc file. ~ /. Bashrc: The file contains bash information dedicated to a user's bash shell. When the user logs on and opens a new shell each time, the file is read. In addition, the variables (global) set in/etc/profile can act on any user ~ The variables (local) set in/. bashrc can only inherit the variables in/etc/profile. They are "Parent-Child" relationships. A netizen summarized the following: /Etc/profile,/etc/bashrc is the global environment variable setting of the system
~ /. Profile ,~ /. Set private environment variables in the bashrc user's home directory
When you log on to the system and obtain a shell process, there are three steps to read the environment configuration file.
1. First, read the global environment variable profile/etc/profile, and then read additional settings documents according to the content, such
/Etc/profile. D and/etc/inputrc
2. Then, read from the Home Directory according to different user accounts ~ /. Bash_profile. If it cannot be read, it will be read ~ /. Bash_login, which cannot be read.
~ /. Profile. The settings of these three documents are basically the same, and reading is preferred.
3. Then, read ~ /. Bashrc
As ~ /. Profile and ~ /. Bashrc is not different
All have personalized features
~ /. Profile can set the user's proprietary path, environment variables, and so on. It can only be executed once during login
~ /. Bashrc is also a user-specific configuration document. You can set the path and command alias. It is used once every shell script execution. From: http://blog.chinaunix.net/uid-24460251-id-2606780.html |