Linux Commands: printenv

Subscribe to my newsletter and never miss my upcoming articles

Listen to this article

printenv is used to print out the environment variables. Environment variables are a common form of setting global values across a terminal session. Environment variables can be set by the systems, automation scripts, or by the user.

You can print your all environment variables using just printenv.

Screenshot 2020-10-18 at 10.37.02 PM.png

If you want to print the value of a specific variable you can use printenv <variable name>.

Screenshot 2020-10-18 at 10.38.24 PM.png


If you are ever stuck and want to know what was the value of the environment variable you can use it. I have found myself using this quite often when debugging issues in production or on my local machine.

If you liked this post please share it with others so that it can help them as well. You can tag me on Twitter @imumesh18. You can subscribe to my newsletter to read more from me.

Comments (2)

Chau Giang's photo

why you do not use just env command?

Umesh Yadav's photo

Hey, so env allows you to print all the environment variables, set a environment variable and disable all the environment variables. But it doesn’t provide a way to print a value of specific environment variable which printenv gives you out of the box. So the use case where you want to print a specific value of environment variable this comes handy