You can use the following commands in Linux and Unix to list or view the environment variables. With the same command you can view a particular environment variable in Linux/Unix and to list all environment variables in Linux/Unix operating systems. The below is the list of commands and their examples:
To display all variables set in current environment you can use any of the following commands without any option e.g. printenv, env, set and export.
The following example will list all environment variables in Linux or Unix shell:
If you know the particular variable name then you can view the content of that variable with printenv command as following:
$ printenv USER
You can use echo command also to view the content of an environment variable but in echo command you have to use dollar sign ($) with variable names, as shown in following example:
$ echo $USER