The printenv
command is used to display the current environment variables in a shell session.
The printenv
command prints all or part of the environment variables that are currently set in your shell. Environment variables are key-value pairs that can affect the behavior of processes on your system.
The basic syntax of the printenv
command is as follows:
printenv [options] [arguments]
-0
, --null
: Output a null character after each variable instead of a newline.variable
: If you specify a variable name as an argument, printenv
will display the value of that specific variable.Here are some practical examples of using the printenv
command:
printenv
printenv PATH
printenv HOME
printenv -0
printenv
when you need to quickly check the values of environment variables without additional formatting.printenv
with other commands like grep
to filter specific variables. For example:
printenv | grep USER
printenv
only shows the environment variables that are currently set; it does not modify them. Use commands like export
to set or change environment variables.