Docs / Linux Basics / How to Manage Environment Variables on Linux

How to Manage Environment Variables on Linux

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 288 views · 1 min read

Environment variables store configuration values that applications use at runtime.

View Environment Variables

# All variables
env
printenv

# Specific variable
echo $PATH
echo $HOME

Set Variables (Current Session)

export MY_VAR="hello"
export PATH="$PATH:/opt/myapp/bin"

Make Variables Permanent

Add to ~/.bashrc or ~/.profile:

echo 'export MY_VAR="hello"' >> ~/.bashrc
source ~/.bashrc

System-Wide Variables

Add to /etc/environment or create a file in /etc/profile.d/:

echo 'MY_VAR="hello"' >> /etc/environment

Was this article helpful?