Several bash Initialization Files

Source: Internet
Author: User
Several bash Initialization Files-general Linux technology-Linux programming and kernel information. The following is a detailed description. (1)/etc/profile
Global (public) configuration. No matter which user, the file is read during logon.

(2)/ect/bashrc
Ubuntu does not have this file, which corresponds to/ect/bash. bashrc
It is also global (public)
This file is read in any way during bash execution.

(3 )~ /. Profile
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 addition, this file will be read when you log on in graphic mode, 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 and can be created.
This 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 is read when bash is executed in the form of non-login. If it is executed in the form of login, the file will not be read.

(7 )~ /. Bash_logout
This 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.

Below are several examples on the local machine:

1. When logging on in the graphic mode, read:/etc/profile and ~ sequentially ~ /. Profile

2. After logging on to the terminal in graphic mode, read:/etc/bash. bashrc and ~ /. Bashrc

3. When logging on in text mode, read:/etc/bash. bashrc,/etc/profile and ~ /. Bash_profile

4. su from another user to this user is divided into two situations:

(1) If the-l parameter (or-parameter, -- login parameter) is included, for example, su-l username, bash is lonin and it 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 logging out, or logging out of the su user, if it is in longin mode, bash will read :~ /. Bash_logout

6. When executing a custom shell file, if the "bash-l a. sh" method is used, 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. In the above example ~ /. 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.