Linux is a multi-user operating system. After each user logs on to the system, there will be a dedicated running environment. Typically, the default environment for each user is the same, and this default environment is actually the definition of a set of environment variables. Users can customize their running environment by modifying the corresponding system environment variables.
Common environment variables
We are not unfamiliar with the environment variables such as path and home. In addition, there are some of the following common environment variables.
Histsize refers to the number of bars in which history command records are saved.
LogName refers to the current user's login name.
Hostname refers to the name of the host, which is usually obtained from this environment variable if the host name is to be used.
The shell refers to which shell the current user is using.
Lang/languge is a language-dependent environment variable, and users with multiple languages can modify this environment variable.
Mail refers to the current user's message storage directory.
PS1 is the base prompt, and for the root user is #, for the average user is $. PS2 is a secondary prompt, and the default is ">". You can modify the current command character by modifying this environment variable, such as the following command to modify the prompt to a string "Hello,my newprompt".
# ps1= "Hello,my newprompt"
hello,my newprompt
In addition to these common environment variables, many applications will add environment variables when installing, such as using Java to set up Java_home and Classpath, and installation Wubi Input method will increase the environment variable "xmodifiers= @im =fcitx" and so on.
customizing environment variables
Environment variables are closely related to the shell, and the user starts a shell after logging in to the system. It's usually bash for Linux, but it can be reset or switched to another shell. Environment variables are set through shell commands, and set up environment variables that can be used by programs run by all current users. For bash, the shell program can access the corresponding environment variables through the variable name, setting the environment variable by export. Here are several examples to illustrate.
1. Show Environment Variables Home
$ echo $HOME
/home/terry
2. Set up a new environment variable welcome
$ export Welcome= "hello!"
$ echo $WELCOME
hello!