export(1)
Set or display environment variables in the current shell and its child processes.
Synopsis
export [OPTION] [NAME[=VALUE] ...]Description
The export command marks shell variables as environment variables, making them available to child processes spawned from the current shell. Without arguments, it displays all currently exported variables. When used with NAME=VALUE, it sets the variable and exports it in one step.
Exported variables are inherited by all subshells and programs launched from the current shell. Changes made to exported variables only affect the current shell session and its descendants, not the parent shell or other login sessions.
Common options
| Flag | What it does |
|---|---|
-p | Display all exported variables in a format that can be reused as input |
-n | Remove the export property from a variable (unexport it) |
-f | Export shell functions in addition to variables |
Examples
Add /usr/local/bin to the beginning of PATH, making it available to all child processes
export PATH=/usr/local/bin:$PATHList all currently exported environment variables in the shell
exportCreate and export a new variable MY_VAR with value 'Hello World'
export MY_VAR="Hello World"Display exported variables in reusable format and filter for HOME
export -p | grep HOMEUnexport TEMP_VAR so it won't be passed to child processes
export -n TEMP_VARSet JAVA_HOME for the java command that follows in the same shell
export JAVA_HOME=/usr/lib/jvm/java-11 && java -version