Method 1: Add a variable to the/etc/profile file (valid for all users permanently)] Use VI to add a variable to the/etc/profile file. This variable will be valid for all users in Linux and will be "permanent ". To make the modification take effect immediately, run the following code # source/etc/profile method 2: In the user directory. add the variable "effective for a single user (permanent)" to the bash_profile file and use VI in the user directory. add a variable to the bash_profile file. The variable quantity is valid only for the current user and is "permanent ". To make the modification take effect immediately, you need to execute the following code in the user directory # source. bash_profile method 3: directly run the export command to define the variable [only valid for the current shell (BASH) (temporary)] use the [export variable name = variable value] to define a variable under the shell command line. This variable is only available in the current shell (BASH) or its subshell (BASH) if the shell is disabled, the variable becomes invalid. When the new shell is opened, the variable does not exist. If you need to use the variable, You need to define it again. Example: export PATH =/usr/local/webserver/php/bin: $ PATH