The order in which the Bash shell launches the configuration script

Source: Internet
Author: User

1. The way bash checks the environment variable file depends on how the system runs the shell, typically there are 3 ways the system runs the shell:

1 shell that runs by default after the system user logs on 2 ) Non-login interactive run shell 3) Execute script to run non-interactive shell

2. In the first case, when the user logs into the Linux system, the shell is launched as a login shell, at which point the shell loads the configuration file in the order:

1) First load/etc/profile, this is the Linux system default shell master configuration file, each login user will be loaded.  2) after loading 1, thescript files under the/etc/PROFILE.D directory are executed, and there are many scripts in this directory, which are scripts that need to be run immediately after the user logs on.  3) After running $home/.bash_profile, this file will call $HOME/.BASHRC (if there is, then execute, if not, do not), in the $HOME/.BASHRC file will find/etc/ BASHRC (also if there is, execute, no, do not execute).

3, if the user's shell is not launched when landing, such as: Manually knocked down when the bash started, or other do not need to enter the password login, remote SSH connection, such as the situation, this non-landing shell will only load $HOME/.BASHRC, and will go to find/ETC/BASHRC, The situation is as shown in 2.3.

4, if you want to be in a non-landing shell can also read the settings of environment variables, etc., you need to write variable settings such as $HOME/.BASHRC or/ETC/BASHRC, rather than Home/.bash_profile or/etc/profile

5. In the configuration file, export is commonly used to define environment variables, and export is the role of exporting variables to all processes in the shell.

The order in which the Bash shell launches the configuration script

Related Article

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.