The Linux environment configuration file is divided into two categories, one for all users and one for the current user. (The following are examples of Ubuntu, other distributions are similar)
For all users:
/etc/profile--will be executed when the user logs on and needs to be reloaded to take effect.
/etc/bash.bashrc--is executed when the user opens the bash shell, and a shell is opened again to take effect.
In the same vein, for a single user:
~/.profile--is executed when the user logs on and requires a reload to take effect.
~/.bashrc--is executed when the user opens the bash shell, and a shell is opened again to take effect.
The most commonly written in the configuration file is the addition of new environment variables and self-launcher programs.
Several commands related to environment variables include:
export--Setting an environment variable (valid only in the current shell window)
echo--show a variable
env--Display all valid environment variables for the current user
unset--Deleting a variable
Source xxxx--applies a configuration file for the variable to take effect (only for the current shell)
A common omission is to forget to write the Export command in the config file, but only write xxx=abc, which is a local variable rather than an environment variable (that is, a variable that is used only in the current script). At this point, if it is written in. Profile, then the login is invalidated, so the shell is not the echo of this variable. Of course, if you are in this shell, source. Profile, again. If it is written in the. BASHRC, it can still be echo in the shell (because it will be executed when the shell is opened), but it will still not appear in the ENV command. So make sure to add to the environment variables and don't forget to export. In fact, from the export of the literal meaning of understanding more accurate-output this variable into the environment.
This article from the "Empty" blog, reproduced please contact the author!
Linux Environment Profile Classification