Linux environment, when the user through the shell operation, the system will be the user of the initial environment variables, such as the system Common resource path: Paths, include, bin and other directories. Shell mode, execute export, view user environment variables, echo $key query an environment variable.
There are two ways to set environment variables, divided into temporary settings, and permanent settings.
A. Temporary settings (real-time effective)
Shell Mode execution:
Export path= "$PATH:/opt/au1200_rm/build_tools/bin"
B. Permanent settings
#行尾追加 Export ...
Vi/etc/profile
Export path= "$PATH:/opt/au1200_rm/build_tools/bin"
Vi/root/.bashrc
Export path= "$PATH:/opt/au1200_rm/build_tools/bin"
As you can see, the process of setting environment variables is consistent. Shell mode, executes the script directly, imports the environment variable into memory, so it takes effect in real time, the environment variable (isolation) cannot be used by other shell environments. Permanent settings, in/etc/profile,/ROOT/.BASHRC file end Append export key= "value" These two files are automatically executed when the user opens the Shell client, where/ROOT/.BASHRC priority is higher than/etc/ Profile. The following tests can be done:
Vi/etc/profile
Export test= "Test1"
Vi/root/.bashrc
Export test= "$TEST: Test2"
Enter export in the new shell mode, result:
Declare-x test= "Test1:test2"
The/etc/profile script is therefore preceded by/ROOT/.BASHRC, which can overwrite the former.
Resources
http://blog.csdn.net/bailyzheng/article/details/7488769
Linux environment variable configuration