Environment variables in Linux: env and export
Updated July 3, 2026
An environment variable is a name-value pair that a process passes down to its children.
Common cases
env # all environment variables
echo "$HOME" # the value of one variable
export EDITOR=vim # create and export
NAME=value command # set a variable for one command onlyHow it works: export and inheritance
A plain variable
x=5lives only in the current shell.export xmarks it as an environment variable, and then every process started from that shell (its children) receives it. Inheritance goes one way, down: a child cannot change its parent's environment. That is why settings likeEDITORorPATHare exported, so the programs you launch can see them.
Used in
You need this in the lesson The shell environment. The theory is the chapter The shell environment and configuration.
See also
The PATH variable, The ~/.bashrc file.
Try it
Open the sandbox: a real throwaway Linux terminal in your browser. Run the commands above by hand - the container is deleted when you leave.