Linux Setting Environment variables

Source: Internet
Author: User

environment variable Background

Linux is a multi-user operating system, each user logged into the system, there is a dedicated operating environment, usually the default environment variables for each user is the same, users can modify their own environment variables to achieve custom purposes. Environment variables are closely related to the shell, the user login system is to start a shell, for Linux is generally bash, you can reset or switch. Depending on the release, Bash has two basic system-level configuration files:/etc/profile,/ETC/BASHRC. These configuration files contain two different sets of variables: Shell variables and environment variables, shell variables are local, environment variables are global.

setting, using Variables

1 , display environment variables

Echo $PATH

2. Setting and modifying environment variables

Export test_path= "/tmp"

3. Show all environment variables

Env

4. Show locally defined shell variables

Set

5. Set read-only

ReadOnly Test_path

6. Clear Environment variables

Unset Test_path

7. Modify File Settings environment variables

Modify the. bash_profile file, the source command in the user's home directory to make the environment variable effective

Vim ~/.bash_profile & Source ~/.bash_profile
Summary

I. Types of variables

1, Permanent: Modify the configuration file, the permanent effect;

2. Temporary: Export command declaration, close Shell invalidation

Ii. three ways to set up variables

Method Role user Effect Aging
Vim/etc/profile & Source All Users Permanent effect
Vim ~/.bash_profile & source Current user Permanent effect
Export definition Variables Current Shell Temporary, disable after shell is closed

Linux Setting Environment variables

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.