How do you display environment variables?

Answer

printenv prints all environment variables. printenv VARNAME prints a specific variable's value. env also lists all environment variables. echo $VARNAME prints a specific variable (e.g., echo $PATH). set shows all shell variables (including local ones not in the environment). declare -p shows all declared variables with their attributes. To see the environment of a running process: cat /proc/PID/environ | tr '\0' '\n'. Use export -p to see all exported variables in a format that can be re-used in another shell.