How to show an environment variable’s current value

command lineenvironment-variables

When I check on my system's environment, a lot of environmental variables will pop up. How can I just search for a particular variable?

A book I'm reading says:

Sometimes the number of variables in your environment grows quite
large, so much so that you don't want to see all of the values
displayed when you are interested in just one. If this is the case,
you can use the echo command to show an environment variable's current
value.

How do I do this in a Linux terminal?

Best Answer

Just:

echo "$VARIABLENAME"

For example for the environment variable $HOME, use:

echo "$HOME"

Which then prints something similar to:

/home/username

Edit: according to the comment of Stéphane Chazelas, it may be better if you use printenv instead of echo:

printenv HOME
Related Question