Bash environment configuration file

Source: Internet
Author: User

Bash environment configuration file
1. The difference between login shell and non-login shelllogin shell is that login is logged on. Login shell: through the complete login process, for example: login through the tty1-tty6, you need to enter the user's account and password, the bash obtained at this time is login shell. Non-login shell: The method for obtaining the bash interface does not need to be logged on repeatedly. For example, the following two methods: 1. After logging on to linux using X Window, start the terminal on the x gui, at this time, the terminal did not enter the user name and password again. The bash environment is non-login shell 2, and bash is executed again in the original bash environment. The user name and password are also not entered. In this case, the second bash, sub-process, which is non-login shell.
The configuration files read by login shell and non-login shell are different.
2. login shelllogin shell reads two configuration files: 1./etc/profile 2 .~ /. Bash_profile, or ~ /. Bash_login, or ~ /. Profile.
2.1/etc/profile is the overall configuration of the user. It is best not to modify this file unless the overall environment is set for all users. The variables set in this file mainly include: PATH: Follow the USER settings USER: username HOSTNAME: hostname histsize: Number of historical commands. This file will call the following file:/etc/inputrc: mainly sets bash hotkeys, [Tab] whether there is sound, etc. /Etc/profile. d /*. sh: Specifies the color and language of the bash interface. If you want to set configuration variables for all users. d/directory. sh file. /Etc/sysconfig/i18n: this file is called by the/etc/profile. d/lang. sh file and sets the language family used by bash by default.
2.2 ~ /. Bash_profilebash reads the complete environment variable/etc/profile and reads the personal configuration. There are three main files: 1 .~ /. Bash_profile 2 .~ /. Bash_login 3 .~ /. Profile will only read one of the files in the above order. As long as the previous file exists, it will not be read later.

$ vim ~/.bash_profile # .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then     . ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/binexport PATHunset USERNAME
This file will be read ~ /. Bashrc file. Source and. to read the configuration file.
]$ source .bashrc ]$ . .bashrc 
3. non-login shellnon-login shell will read ~ /. Bashrc to view the file:
# .bashrc# User specific aliases and functions# Source global definitionsif [ -f /etc/bashrc ]; then     . /etc/bashrcfialias rm='rm -i'
Will Read/etc/bashrc this file will be set: Set umask PS1 according to UID: prompt call/etc/profile. d/*. sh
4. Other directories in the/etc/man. config configuration manual, man command ~ /. Bash_history record the bash History command ~ /. Bash_logout some processing that the system wants to do when logging out bash.

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.