Original text: http://www.cnblogs.com/siqi/p/3604354.html
View global environment variables: env
View all environment variables: set
Delete a variable: unset [variable name] #Only for the current session
Set a variable: name=songjiankang
export name # Promote this variable to global, note that only the current session can access it, and it must be written to the file if it can be accessed next time
Configuration file for environment variables:
Global: /etc/profile
Local: ~/.bash_profile
Several common environment variables:
$USER, $LOGNAME
$UID, $SHELL, $HOME,
$PWD, $PATH
$ PS1: [\ u @ \ h \ W] \ $
$PS2: The symbol to enter after typing the wrong
$PATH: determines which directories the shell will look for commands or programs in. The value of PATH is a series of directories separated by colons
Note: It is best not to put "./" in the PATH, this will cause security problems
Ways to view the PATH value: echo $PATH or export
Modify environment variables
1. Modify directly with commands but only take effect in the current session
export JAVA_HOME=/usr/local/java #Add new variable name
export PATH=$PATH:/usr/local/php/bin #Modify the existing variable name
Test for success: echo $JAVA_HOME or the env command,
2. Modify the global configuration file
vim /etc/profile
At the end of the document, add: export PATH=$PATH:/usr/local/php/bin
Execute source /etc/profile otherwise you need to rewrite the login
3, similar to the personal environment variable configuration file
vim ~/.bash_profile
The following steps are the same as 2