$linuxjunkies
>

export(1)

Set or display environment variables in the current shell and its child processes.

UbuntuDebianFedoraArch

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

FlagWhat it does
-pDisplay all exported variables in a format that can be reused as input
-nRemove the export property from a variable (unexport it)
-fExport 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:$PATH

List all currently exported environment variables in the shell

export

Create 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 HOME

Unexport TEMP_VAR so it won't be passed to child processes

export -n TEMP_VAR

Set JAVA_HOME for the java command that follows in the same shell

export JAVA_HOME=/usr/lib/jvm/java-11 && java -version

Related commands