To show environment variables in Linux, you typically use printenv, env, set, or echo for individual variables.

🧩 Quick Scoop: How Linux Shows Environment Variables

1. Show all environment variables

These commands list the current environment of your shell:

bash

printenv

or:

bash

env

Both print a list of NAME=VALUE pairs for the environment variables currently set for that process. For easier scrolling:

bash

printenv | less
env | less

To search for something like PATH:

bash

printenv | grep PATH

2. Show a single environment variable

If you know the variable name, use printenv or echo:

bash

printenv HOME
printenv PATH

or:

bash

echo "$HOME"
echo "$PATH"

echo is also what you’ll see in most tutorials and scripts.

3. Show all variables (env + shell)

If you want not only environment variables but also shell variables and functions (often for debugging), use:

bash

set

Because this output is huge, pipe it to a pager:

bash

set | less

4. Quick “what’s my environment” checklist

Common one‑liners you’ll actually use day‑to‑day:

bash

# All environment variables
printenv

# One specific environment variable
echo "$USER"
echo "$SHELL"

# Filtered list
env | grep PATH

# Everything (shell + env + functions)
set | less

TL;DR

  • Use printenv or env to list environment variables.
  • Use echo $VAR or printenv VAR to show a specific variable.
  • Use set if you need everything , including shell variables and functions.

Information gathered from public forums or data available on the internet and portrayed here.