The environment variables can be stored in various configuration files depending upon the program that you are referring to as well the scope - system-wide or user-specific.
System-Wide Environment Variables:
You can find the system-wide environment variables under /etc/environment file.
# cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:
/usr/games:/usr/local/games:/snap/bin"
User-Specific Environment Variables:
Based on what shell you use, you can find them under the ~/.bashrc or ~/.zshrc files under the home directory.
Example:cat ~/.bashrc
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
# ... or force ignoredups and ignorespace
HISTCONTROL=ignoredups:ignorespace
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

Know the Temporary Environment variables:
If you are looking for the temporary environment variables set for the current session then you can make use of the printenv command.
Example:# printenv
HOSTNAME=b9fc21f2fc40
HOME=/root
TERM=xterm
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/user/bin
DEV_SERVER_URL=https://192.167.8.2:8000
PWD=/
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!