Linux Configuration environment variables

Source: Internet
Author: User

Files for environment variables in Linux

When you enter the system, Linux will read the environment variables for you, where the environment variables are stored, which is the file of the environment variables. There are many files in Linux that record environment variables, which are read in a certain order by the system.

1./etc/profile:

This file is a system environment variable that sets the environment information for each user and is executed when the user logs on for the first time. and collect the shell settings from the configuration file of the/ETC/PROFILE.D directory.

This file is a file that any user will read after logging into the operating system (if the user's shell is csh, tcsh, zsh, the file will not be read), used to obtain the system's environment variables, only read once when logging in.

Assuming that the user is using bash, then

2./ETC/BASHRC:

After the/etc/profile content is executed, if the user's shell is running bash, then the file is executed. In addition, each time a new bash shell is opened, the file is read.

Each user who uses bash executes the/etc/profile after logging in and executes the file when a new bash is opened. So, if you want each user who uses bash to do something for each new bash and every login, or to define some new environment variables, you can set it up in this.

3. ~/.bash_profile:

Each user can use the file to enter shell information that is specific to their own use. When the user logs on, the file is executed only once, by default, it sets some environment variables to execute the user's. bashrc file, which is recommended for setting environment variables.

A single user The modification of this file will only affect every subsequent landing system. Therefore, it is possible to set a specific environment variable or special operation for a single user here, then it will fetch these new environment variables or do some special operations on each login, but only when landing.

4. ~/.BASHRC:

The file contains bash information dedicated to a single-person bash shell, which is read when logged in and every time a new shell is opened. Do not set this inside, every time will be read, will affect efficiency.

A single user The modification of this file will affect every subsequent landing system and a new bash for each time he opens. As a result, you can set a specific environment variable or special operation for a single user here, and each time it has a new login system or a new bash, it will get the corresponding special environment variables and special operations.


Mac: User-level environment variable settings ~/.bash_profile Add the appropriate environment variable with VI open

Note: the path Intermediate: (colon) split, the environment variable can not be immediately effective after adding the source ~/.bash_profile immediately refresh the file to take effect


Linux Configuration 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.