Skip to content

printenv command in UNIX

Terminal window
printenv [OPTION]... [VARIABLE]...

Print the values of the specified environment VARIABLE(s). If no VARIABLE is specified, print name and value pairs for them all.

The only option is:

  • -0, --null: end each output line with NUL, not newline (\n)

It also has --help and --version options, like all the commands.

Note that your shell may have its own version of printenv, which usually supersedes the version described here. Please refer to your shell’s documentation.

Terminal window
# print the list of environmental variables
printenv
SHELL=/bin/bash
HOME=/home/pit
# many others
# print only certain variables
printenv USER HOME
pit
/home/pit

Manual reference: