Execution sequence of the. bash_profile. bashrc profile file

Source: Internet
Author: User


The difference between a login shell and an interactive non-login shell is that a login shell refers to the shell obtained when a user logs on to the system. The logon shell is an interactive shell. Login
Shell looks for four different startup files to process the commands. The order in which bash shell processes files is as follows:
Www.2cto.com 1:/etc/profile
2:/etc/profile. d. Wait for the configuration file
3: $ HOME/. bash_profile
4: $ HOME/. bash_login
5: $ HOME/. profile/etc/profile is the main default startup file of bash shell on the system. Every user on the system will execute this file upon login. By setting this file, Super Users can create default features for all bash users in the system. Different Linux versions
Commands placed in this file are different. In redflag, this file sets several important variables, such as path user logname mail hostname histsize inputrc. For details, you can view the specific file.
The remaining three files in www.2cto.com have the same functions-provide user-specific startup files. Most Linux versions only use
. For example, RedFlag uses. bash_profile for ubuntu and uses. profile. shell for searching ~ /. Bash_profile,
~ /. Bash_login,
~ /. Profile (~ Is the stenographer of the user's main directory), and execute the command in the first file it finds. You can place commands in these files to overwrite the/etc/profile file.
Default settings. That is, the subsequent files can overwrite or modify the previous settings. Www.2cto.com interactive non-Logon shell if a bash shell is started without an equest system (such as typing bash at the CLI prompt), an interactive
The initialization file (such as. bash_profile) for logging on to shell instead of logging on to shell usually runs this file. In this way, the logon shell and non-Logon
Shell can all use commands in. bashrc.
For example, when you log on to Linux in the X Window environment, the terminals started in the X environment are non-Logon shells. In the interactive non-Logon shell, the commands in the initialization file mentioned above are not executed. However, the interactive non-Logon shell
The logon shell inherits the shell variables set by these initialization files. $ HOME/. bashrc
Interactive non-Logon shell execution ~ /. Commands in the bashrc file. The file will be re-read every time the shell script is executed,
So it is the most complete. But everything is different. The debain series are different, such as ubuntu/etc/profile -- </etc/environment -- <$ HOME/. 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.