Linux environment variable configuration

Source: Internet
Author: User

(1)/etc/profile will be executed during logon.
global (public) configuration, regardless of the user, reads the file upon logon.
(2) this file does not exist in/ECT/bashrc ubuntu. It corresponds to/ECT/bash. bashrc
Bash. bashrc is the initialization file of the interactive shell.
(3 )~ /. Profile the configuration read by a user.
if Bash is executed in the login mode, read ~ /. Bash_profile. If it does not exist, read ~ /. Bash_login. If the first two do not exist, read ~ /. Profile.
in graphical mode, this file is read even if ~ /. Bash_profile and ~ /. Bash_login.
(4 )~ /. Bash_login
if Bash is executed in the login mode, read ~ /. Bash_profile. If it does not exist, read ~ /. Bash_login. If the first two do not exist, read ~ /. Profile.
(5 )~ /. Bash_profile unbutu does not have this file by default. You can create a new file.
the file is read only when Bash is executed in the form of login. This configuration file is usually configured to read ~ /. Bashrc.
(6 )~ /. Bashrc this file contains bash information dedicated to a user's bash shell. When the user logs on and opens a new shell each time, the file is read.
when Bash is executed in the form of non-login, the file is read. If it is executed in the form of login, the file will not be read.
(7 )~ /. Bash_logout
the file is read only when it is logged out in Longin format. That is to say, when you log out in text mode, the file will be read, and when you log out in graphic mode, the file will not be read.

Supplement
Please note that/etc/rc. Local is the file that the system shell will execute and will exit after Linux is started;/etc/profile or
/Etc/bash. bashrc is the configuration of the User Shell. The common shell is the sub-process of the User Shell, not the sub-process of the system shell.
The alias "alias LL = 'LS-a'" specified in/etc/rc. Local is useless for the shell after logging on to the system.

A netizen summarized the following:
/Etc/profile,/etc/bashrc is the global environment variable setting of the system
What is the difference between/etc/profile and/etc/bashrc?
The previous one is mainly used to set some system variables, such as java_home. The next one is mainly used to save some bash settings.
~ /. Profile ,~ /. Set private environment variables in the bashrc user's home directory
When you log on to the system and obtain a shell process, there are three steps to read the environment configuration file.
1. First, read the global environment variable profile/etc/profile, and then read additional settings documents according to the content, such
/Etc/profile. D and/etc/inputrc
2. Then, read from the Home Directory according to different user accounts ~ /. Bash_profile. If it cannot be read, it will be read ~ /. Bash_login, which cannot be read.
~ /. Profile. The settings of these three documents are basically the same, and reading is preferred.
3. Then, read ~ /. Bashrc
As ~ /. Profile and ~ /. The differences between bashrc and bashrc are all customized.
~ /. Profile can set the user's proprietary path, environment variables, and so on. It can only be executed once during login
~ /. Bashrc is also a user-specific configuration document. You can set the path and command alias. It is used once every shell script execution.

The following are several examples:
1. When logging on to the graph mode, read:/etc/profile and ~ in sequence ~ /. Profile
2. After logging on to the graphical mode, read/etc/bash. bashrc and ~ in sequence when the terminal is opened ~ /. Bashrc
3. When logging on in text mode, read:/etc/bash. bashrc,/etc/profile and ~ sequentially ~ /. Bash_profile
4. there are two cases:
(1) if the-l parameter (or-parameter, -- login parameter) is included, for example: su-l username, bash is lonin, which reads the following configuration files in sequence:/etc/bash. bashrc,/etc/profile and ~ /. Bash_profile.
(2) if the-l parameter is not included, bash is non-login, which reads:/etc/bash. bashrc and ~ sequentially ~ /. Bashrc
5. When you log out, or log out of the su user, if it is in Longin mode, Bash will read :~ /. Bash_logout
6.
If "bash-L
. sh, Bash will read the rows:/etc/profile and ~ /. Bash_profile. If other methods are used, such as Bash. sh,
. /. sh, sh. sh (this does not belong to bash shell), it will not read any of the above files.
7. The above example reads ~ /. Bash_profile. If the file does not exist, read ~ /. Bash_login. If the first two do not exist, read ~ /. Profile.

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.