Interview Prep/Linux/Packages, Shell & Text Tools

What are environment variables vs shell variables?

BeginnerConceptPackages, Shell & Text Tools
Answer

A shell variable exists only in the current shell. export marks it as an environment variable, copied into every child process's environment.

APP_ENV=prod            # shell only
export APP_ENV          # now inherited by children
APP_ENV=dev ./run.sh    # set only for this one command
env | sort; printenv PATH
unset APP_ENV

Children can never change the parent's environment.

All Linux questions Roadmap: Linux

More on Packages, Shell & Text Tools