Differences between set, env, and export and setenvexport

Source: Internet
Author: User

Differences between set, env, and export and setenvexport

Set: display the current shell variables, including the current user Variables

Env: Display User Variables

Export: displays the shell variables currently exported as user variables.

For example:

Root @ kali :~ # Aaa = bbb: Set a variable. The variable set at this time is a shell variable.
Root @ kali :~ # Echo $ aaa display the variable you just set
Root @ kali :~ # Set | grep aaa display and search for the current shell variable, find the aaa variable you just set
Aaa = bbb
Root @ kali :~ # Env | grep aaa: displays and searches for the variables of the currently logged-on user. aaa is a shell variable and cannot be searched.
Root @ kali :~ # Export aaa export the shell variable aaa to the user variable
Root @ kali :~ # Env | grep aaa: Search for user variables to search for aaa.
Aaa = bbb
Root @ kali :~ #

Each shell has its own unique variables, which are different from user variables. The current user variables have nothing to do with what shell you use, no matter what shell you use. Such as HOME and SHELL, but shell also has its own variables. Different shells are different, such as BASH_ARGC and BASH. These variables are only displayed in set, is unique to bash. When an export parameter is not added, it shows which variables are exported as user variables, because a shell variable can be changed to a user variable through export "export.

Run the unset command to clear environment variables. You can use unset to clear all variables set by set env export.

In addition, the shell (bash here) initialization process is as follows:

1. bash check whether the file/etc/profile exists

2. If yes, bash will read the file. Otherwise, skip

3. bash check whether the file. bash_profile in the main directory exists.

4. If the file exists, bash reads the file. Otherwise, skip

5. bash check whether. bash_login in the main directory exists.

6. If the file exists, bash reads the file. Otherwise, skip

7. bash check whether the file. profile in the main directory exists

8. If the file exists, bash will read the file. Otherwise, it will be skipped.

After these steps are completed, a prompt is displayed. The ksh default prompt is $.





In linux, the set, export, and env commands work the same way when setting shell variables?

Env is the display variable.
Set and export are set variables.
Set for csh Environment
Export for bash Environment
Format: set DISPLAY 0
Export DISPLAY = 0

The differences between env, set, and profile in unix

I just made soy sauce.

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.