[Reprint] The reading order of environment variables under Linux

Log in to the system to read the steps:

    When a shell process is obtained when logging in to the system, it has three steps to read the environment configuration file:

  • 1. The first thing to read is the global environment variable setting directory /etc/profile, and then read additional setting documents according to its content, such as /etc/profile.d and /etc/inputrc

  • 2. Then go to the user's home directory, read ~/.bash_profile, otherwise read ~/.bash_login, and then otherwise ~/.profile, these three document settings are basically the same, there is a read priority relationship

  • 3. Then go to the user's home directory and read ~/.bashrc

The difference between /etc/* and ~/.*:

  • /etc/profile, /etc/bashrc are system global environment variable settings

  • ~/.profile, ~/.bashrc are private environment variable settings in the user's home directory

The difference between ~/.profile and ~/.bashrc:

  • All have personalization features

  • ~/.profile can set user-specific paths, environment variables, etc. It is only executed once at login

  • ~/.bashrc is also a user-specific setting document, you can set the path, command alias, and it will be used once every time the shell script is executed

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Please indicate the author and source for reprinting: http://blog.csdn.net/c406495762/article/details/62902871

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325522807&siteId=291194637