Configuring Linux operating system environment variables

  

1. Linux is a multi-user operating system. Each user logs into the system and has a dedicated runtime environment. Usually the default environment for each user is the same. This default environment is actually a definition of a set of environment variables. Users can customize their own operating environment by modifying the corresponding system environment variables.

2, often modify the environment variables in the /etc/profile file, the content modified here is for all users.

The following main operations will be performed in this file.

3, how to add environment variables.

For example, add “NAME=liheng” .

Add the following at the end of the profile file export NAME=liheng

The variable value liheng can be quoted or not, the effect is the same. w

4. The content added or modified in the profile file needs to be logged off to take effect.

5. How to understand the definition of variables repeatedly.

What happens often is the definition of the PATH variable.

For example: in the peofile file, the default PATH variable is set to PATH=¥¥¥¥¥¥¥, which may be set in the PATH in the future, generally added to the last PATH=·· ···· (for example). The PATH=·······\\¥¥¥¥¥¥¥¥, which is recognized in the system, means that the environment variable of the same name will work first. Everyone must pay attention.

6, special characters introduced.

For example, the following contents are included in the profile, and the usage of the special symbols is explained by the following.

export A=/q/jing:aaa/cc/ld

export B=.:/liheng/wang

export A=/cd/cdr:$A

Everyone pays attention to the red symbol:

: Indicates the parallel meaning. For example, there are multiple values ​​of the A variable, and the symbol is used for separation.

. Indicates the current directory of your operation. For example, the pap command will look for the B environment variable.

Type the pap command in /home, the system first finds the content of B in the /home directory (that is, the current path), if you do not find the content about B in the /liheng/wang directory.

$ represents the value of this variable before this definition, for example $A for /q/jing:aaa/cc/ld. That is to say

A=/cd/cdr:/q/jing:aaa/cc/ld

Copyright © Windows knowledge All Rights Reserved