Linux environment variable Configuration

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.