Linux environment variable description-ENV/set/Export

Source: Internet
Author: User

--- Excerpt from laruence's private dish-

Http://linux-vbird.bluedata.org/linux_base/0320bash.htm#variable

Although

Http://blog.csdn.net/zhuying_linux/article/details/6633022

Http://blog.csdn.net/longxibendi/article/details/6125075

But the statement about Linux variables is still a bit confusing.

Let's proceed as laruence says.

1. A variable is a set of characters or symbols to replace some settings or a string of reserved data!

2. variables are divided into environment variables and custom variables.

Environment variables such as path, home, mail, Shell, etc. are usually expressed with uppercase letters!

3. env

Display the content of the main preset variables in the current system. This command mainly reads the main variables in the current system and does not read the custom variables.

4. Set

Displays all the variable content in the current system. In addition to the current "environment variables", it also displays your "Custom variables 』.

Two important words:

1. Using set will show the default values of the system, and all the associated variables will be shown! At the same time, it should be noted that if many people are online at the same time, your variables can only be used for yourself (unless you change the system's preset parameter file, such as/etc/profile), without interfering with others! As mentioned above, because you will get a PID after logging on to Linux, and your settings will only be related to this PID and the subroutine! In addition, if the variable settings for this login are not changed, the variables set for this login will be canceled at the next login (because the program
PID is missing !)! So, if you want your variables to be automatically set every time you log on, you must write your settings to the configuration file loaded during login!

2. after you get a bash, you get a program, but if you execute bash again, you will enter the "subroutine 』, we will discuss the concept of this program in detail in the Resource Management chapter. Here you have a concept first. As you have already entered this subroutine, the variable settings in the parent program will no longer exist. If you want to continue using the variable content in the subroutine, execute the: Export variable! It is very important to use this item to reference others' archives or other programs! This is especially true if two or three files are referenced by each other.
If export is used, the same variable values in different files must be set repeatedly! Therefore, if I use export in the first file, the variable content will be read in subsequent file references! Easy to use? If only the export is issued and no variable is connected, all the "environment variables" will be displayed! That is to say, export can change a custom variable to an environment variable!

Bytes:

[Oracle @ zhou3 ~] $ AAA = BBB -- custom variable [Oracle @ zhou3 ~] $ Echo $ aaa bbb [Oracle @ zhou3 ~] $ ENV | grep AAA -- the environment variable does not contain [Oracle @ zhou3 ~] $ Set | grep AAA -- set can output the custom variable AAA = BBB [Oracle @ zhou3 ~] $ Export | grep AAA -- before the export custom variable, export itself does not output this value [Oracle @ zhou3 ~] $ Export AAA -- use export to export custom variables into environment variables. [Oracle @ zhou3 ~] $ ENV | grep AAA -- later, the subroutine can use this variable AAA = bbb

 

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.