whatis environment-variable
Environment Variable
Also known as: env var
A named value such as HOME or PATH that is passed from a process to its children and used to configure program behavior.
What Is an Environment Variable in Linux?
Every process has an environment: a list of NAME=value strings inherited from its parent. Shells distinguish plain shell variables from exported ones; only exported variables reach programs you start.
Set one for a single command with VAR=value command, or for the session with export VAR=value. Persistent variables usually go in ~/.bashrc, ~/.profile, or /etc/environment, and systemd services set theirs with Environment= lines.
Example
export EDITOR=vim
printenv | sort Learn more about Environment Variable
- Environment Variables and PATH Explained Environment variables control how your shell and the programs it launches behave, and PATH is the most important one, determining which commands your system can find. This guide covers viewing, setting, and permanently persisting environment variables.
- bashrc vs bash_profile vs profile: Which File to Put Things In Login shells read one set of files, interactive shells read another, and non-interactive shells read almost nothing. That is why your PATH works in a terminal and not in cron, and why your alias vanishes over ssh.
- XDG Base Directories Explained: Why Your Home Folder Is a Mess The specification that sorts config from cache from data, what each variable actually means, which programs ignore it and what you can do about them, and why deleting the wrong directory loses your data.