A brief introduction to the environment variables and configuration files of Ubuntu in Linux __linux

Source: Internet
Author: User

1.5 Common configuration files in Ubuntu
1)/etc/profile
2/etc/environment environment variable defined in this file, you can view the contents of the file with Vim/etc/environment
3) ~/.profile
4) ~/.BASHRC
5 ~/.bash_profile This file, checked the relevant, but the system does not have this file;
Description:/etc/profile and/etc/environment files are global in nature, work for all users, and ~/.profile three files that work for the current user;
Note:~ Represents the home directory of the current user, the home directory of the root is/root/, and the normal user's home directory is typically a hidden file/home/the user name/;.BASHRC (with a dot in front of the filename);
2. The difference between normal user and root user login
1 when the root user logs in, the order in which these files are executed is:/etc/profile, the other files will not be loaded (executed);
2 Ordinary users log in, the order to execute the above files is:/ETC/PROFILE,~/.PROFILE,~/.BASHRC, the other two files will not be loaded (execution);
3 It is important to understand the order in which files are executed, so that you can know which file to set the environment variable and can load the environment variable at login;
4 The function of the/etc/environment file is to load the environment variable from the file when the system uses the environment variable, but do not add anything to the file;
3. How to configure environment variables
1 if it is used by all users, configure the environment variable in the/etc/profile file, and configure it in the ~/.profile file if it is used by the user.
2 After the configuration is complete, you need to log on again or execute the following command: Source/etc/profile
4. Some questions about environment variables
1 Why the environment variable is very short in/etc/environment, but when the output command echo $PATH found the environment variable increased a lot.
A: Because the system has loaded your configuration file with commands about importing the environment.
2 in the configuration file, only the value of the imported environment variable is modified, but the path that was added before the output command echo $PATH is still present.
Answer: Because the system does not reload the environment variable, this time only need to reload the file/etc/environment can, source/etc/environment;

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.