Linux environment variable configuration and linux environment variable configuration
In a linux environment, when a user uses shell, the system will convert the environment variables for the user, such as the system public resource path: path, include, bin and other directories. In shell mode, execute export to view the user's environment variables, and echo $ key to query an environment variable.
You can set environment variables in two ways: Temporary settings and permanent settings.
A. Temporary settings (effective in real time)
Shell mode execution:
Export PATH = "$ PATH:/opt/au1200_rm/build_tools/bin"
B. Permanent settings
# Append an export at the end of a row...
Vi/etc/profile
Export PATH = "$ PATH:/opt/au1200_rm/build_tools/bin"
Vi/root/. bashrc
Export PATH = "$ PATH:/opt/au1200_rm/build_tools/bin"
The preceding methods show that the environment variable setting process is consistent. In shell mode, you can directly execute the script to import the environment variable into the memory, so it takes effect in real time. Other shell environments cannot use this environment variable (isolation ). Permanent settings, in/etc/profile,/root /. the bashrc file is appended to the end of the export key = "value". These two files are automatically executed when the user opens the shell client, where/root /. bashrc has a higher priority than/etc/profile. Perform the following tests:
Vi/etc/profile
Export TEST = "test1"
Vi/root/. bashrc
Export TEST = "$ TEST: test2"
Enter export in new shell mode. Result:
Declare-x TEST = "test1: test2"
Therefore, the/etc/profile script is implemented before/root/. bashrc, and the latter can overwrite the former.
References
Http://blog.csdn.net/bailyzheng/article/details/7488769