The RC in the configuration file. bashrc in the home directory indicates resource configuration.
What is login shell? What is a non-Logon shell?
Logon shell refers to the shell that is started after the user enters the user name and password when logging in. (2) The Shell started by the command with the -- login parameter: Bash -- login. For users, the main difference between a login shell and a non-login shell is that the startup file executed when the shell is started is different. I am at/etc/profile ,~ /. Bash_profile ,~ The/. bashrc file names are printed by the echo command. Run the following command:
Wangjk @ wangjiankun :~ $ Bash
. Bashrc
Wangjk @ wangjiankun :~ $ Bash -- Login
Etc/profile
. Bash_profile
. Bashrc
Wangjk @ wangjiankun :~ $
The above results show that the Startup File for Shell login is:/etc/profile ,~ /. Bash_profile ,~ /. Bashrc (here is only the inference obtained from the phenomenon. This inference is problematic and will be discussed later). Instead of logging on to the Startup File executed by shell, the only difference is :~ /. Bashrc.
Bash is used as the Login Shell by/etc/loginProgramThis parameter is specified when the/etc/passwd file is parsed, for example, wangjk: X: 1000: 1000: wangjiankun,:/home/wangjk:/bin/bash, the red color gamut specifies that the user's logon shell is Bash.
In fact, bash is the Startup File executed when the shell is started:
- /Etc/profile
- ~ /. Bash_profile ,~ /. Bash_login or ~ /. Profile, first existing readable file is read
While Bash is read as a non-login shell when it is started ~ /. Bashrc. Note: Bash is not read when you log on to shell ~ /. Bashrc, but in the file ~ /. Bash_profile usually has the following statement to read ~ /. Bashrc:
If [-f ~ /. Bashrc]; then .~ /. Bashrc; FI
The above discussion is interactive bash shell. In fact, there are two working modes of shell: Interactive and non-interactive. When executing scripts, shell works in non-interactive mode. In non-interactive mode, the Startup File Read by Bash is determined by the Environment Variable bash_env. For example ~ In the/. Test file, use the echo command to print the statement: I test non-interactive shell. In the test. Sh script, print the statement: this file is test. Sh. The output result is as follows:
Wangjk @ wangjiankun :~ $
Wangjk @ wangjiankun :~ $ Echo $ bash_env
Wangjk @ wangjiankun :~ $./Test. Sh
This file is test. Sh
Wangjk @ wangjiankun :~ $ Export bash_env = ~ /. Test
Wangjk @ wangjiankun :~ $./Test. Sh
I test non-interactive shell
This file is test. Sh
Wangjk @ wangjiankun :~ $
Note: The blank line in the middle indicates that the environment variable bash_env is empty. Therefore, when the Script test. Sh is run for the first time, only one sentence is output. When the environment variable bash_env is defined ~ /. After test, run the Script test. Sh to print two sentences. The first sentence is the running file ~ /. Test printed.