Back to the command reference

export

ShellFundamentals In simulator In real Linux

Set an environment variable for child processes

Name: export: export a variable to child processes

You can practise it right away in the simulator, and use it in real Linux mode too.

Description

export is a shell builtin that marks variables for export, so every child process started afterwards inherits them. Unexported variables stay private to the current shell.

The effect lasts only for this shell and its children; put exports in ~/.bashrc or ~/.profile to apply them at every login.

Syntax

export NAME[=VALUE]...

Common options

-pList all exported variables
-nRemove the export property
-fExport functions (child shells can use them)

Examples

  • $ export EDITOR=vim

    Set the default editor

    Explain
  • $ export PATH="$PATH:$HOME/bin"

    Add your own directory to PATH

    Explain
  • $ export

    List exported variables

    Explain

Related