Linux systems use environment variables to identify themselves in programs and scripts. This provides an easy way for your program to obtain system information. The question is how to set these variables.
When your Linux system launches a bash shell, bash looks for commands in several files by default. These files are called startup files. The startup file that bash checks depends on how you start the bash shell. There are three ways to start the bash shell:
1, log in as the default login shell
2. As a non-login interactive shell
3. As a non-interactive shell when running scripts
First, login shell
When you log in to a Linux system, the Bash shell is launched as a login shell. The login shell reads commands from 4 different boot files, and the following is the order in which the bash shell handles these files:
1./etc/profile
2. $HOME/.bash_profile
3. $HOME/.bash_login
4. $HOME/.profile
Second, interactive shell
If you are not booting when you are logged into the system (such as typing bash at the command prompt), you are launching the bash shell. It does not access the/etc/profile file after it starts, but goes to the home directory to check
The. BASHRC is present.
. BASHRC has two functions one is to view the BASHRC file in the/etc directory, and the second is to provide a place for users to customize their own command aliases for private script functions.
Third, non-interactive shell
The shell that the system uses to execute shell scripts is the shell
Linux Learning--Positioning System environment variables