Linux Environment Profile Classification

Source: Internet
Author: User

The Linux environment configuration file is divided into two categories, one for all users and one for the current user. (The following are examples of Ubuntu, other distributions are similar)

For all users:

/etc/profile--will be executed when the user logs on and needs to be reloaded to take effect.

/etc/bash.bashrc--is executed when the user opens the bash shell, and a shell is opened again to take effect.

In the same vein, for a single user:

~/.profile--is executed when the user logs on and requires a reload to take effect.

~/.bashrc--is executed when the user opens the bash shell, and a shell is opened again to take effect.


The most commonly written in the configuration file is the addition of new environment variables and self-launcher programs.

Several commands related to environment variables include:

export--Setting an environment variable (valid only in the current shell window)

echo--show a variable

env--Display all valid environment variables for the current user

unset--Deleting a variable

Source xxxx--applies a configuration file for the variable to take effect (only for the current shell)

A common omission is to forget to write the Export command in the config file, but only write xxx=abc, which is a local variable rather than an environment variable (that is, a variable that is used only in the current script). At this point, if it is written in. Profile, then the login is invalidated, so the shell is not the echo of this variable. Of course, if you are in this shell, source. Profile, again. If it is written in the. BASHRC, it can still be echo in the shell (because it will be executed when the shell is opened), but it will still not appear in the ENV command. So make sure to add to the environment variables and don't forget to export. In fact, from the export of the literal meaning of understanding more accurate-output this variable into the environment.


This article from the "Empty" blog, reproduced please contact the author!

Linux Environment Profile Classification

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.