Fundamentals of the ten-year OPS series-Linux
Zeng Lin
Contact: [Email protected]
Website: www.jplatformx.com
Copyright: Please do not reprint the article without permission
First, Introduction
During the shell session invocation environment, the shell stores a large amount of information. Some programs look for variables stored in the environment to adjust their behavior. Knowing this, users can use the environment to customize the shell.
Second, what is stored in the environment
Although the shell stores two basic types of data in the environment, there is essentially no difference between the two types in bash. The two data types are environment variables and shell variables, respectively. The shell variable is a small amount of data that is stored by bash, and the environment variable is all other variables. In addition to variables, the shell stores some programming data, namely aliases and Shell functions.
To understand what is stored in your environment, you need to use the SET command or PRINTENV program integrated in bash. Instead, the set command displays both shell variables and environment variables, and printenv only displays environment variables.
The set command is as follows (which includes environment variables and shell variables):
Printenv command (includes only environment variables):
The environment variable contains quite a few variables, and the following table shows some common interesting environment variables.
| Variable |
Description |
| SHELL |
Native Shell name |
| HOME |
The path name of the native home directory |
| Lang |
Defines the character set and collation for native languages |
| Old_pwd/pwd |
Previous working directory/current working directory |
| PATH |
A list of directories separated by colons that are found when the user enters the name of an executable program |
| PS1 |
The prompt string 1. Defines the contents of the native shell system prompt. |
| Term |
The name of the terminal type. UNIX-like systems support a wide variety of terminal protocols, which define the protocols used by the native terminal emulator |
| USER |
User name |
Iii. How the environment is built
After the user logs on to the system, the Bash program starts and reads a series of configuration scripts called startup files that define the default environment shared by all users. Next, Bash reads more startup files that are stored in the home directory to define your personal environment. The exact order in which these steps are executed is determined by the type of shell session that is started.
(014) Linux Environment