1. Use the ENV command to display all environment variables
$ env
hostname=redbooks.safe.org
Pvm_rsh=/usr/bin/rsh
Shell=/bin/bash
Term=xterm
histsize=1000
...
2. Use the SET command to display all locally defined shell variables
$ set
3. Use the unset command to clear environment variables
Set sets the value of an environment variable. Clear the value of the environment variable with the unset command. If no value is specified, the value of the variable is set to NULL. Examples are as follows:
$ export test= "TEST ..." #增加一个环境变量TEST
$ env|grep Test #此命令有输入, proving that the environment variable test already exists
Test=test ...
$ unset $TEST #删除环境变量TEST
$ env|grep Test #此命令没有输出, proving that the environment variable test already exists
4. Use the echo command to view a single environment variable. For example:
Echo $PATH
5. Common environment variables
PATH determines to which directories the shell will look for commands or programs
Home Current User Home directory
Histsize Number of historical records
LOGNAME The current user's login name
HOSTNAME refers to the name of the host
Shell Current User shell type
Languge language-related environment variables, multiple languages can modify this environment variable
Mail storage directory for the current user of mail
PS1 basic prompt, for root user Yes #, for normal user is $
6. Set a new environment variable Hello
$ export hello= "hello!"
$ echo $HELLO
Hello!
Linux environment variables