Skip to main content

Command referenceexport

export command (Linux / bash / sh / zsh)

Linuxbashshzshsystembeginner

What it does

Mark shell variables for inheritance by child processes. When people search for the export command linux environment variable, they usually want export's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Mark shell variables for inheritance by child processes.

Syntax

export NAME[=VALUE]...

Common options

Flag / optionMeaning
NAME=VALUEAssign and export a value.
-pList exported variables in reusable form.
-n NAMERemove the export attribute in supporting shells.
PATH="$PATH:DIR"Append a directory while preserving PATH.

Practical examples

Set environment

export APP_ENV=production

Makes APP_ENV available to child commands.

Extend PATH

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

Adds a personal executable directory.

Inspect exports

export -p

Lists variables marked for export.

Common mistakes

  • Adding a path with an unquoted expansion.
  • Expecting export in one terminal to persist in future sessions without editing shell startup files.

FAQ

What does export do in Linux?

Mark shell variables for inheritance by child processes.

How do I use export from the terminal?

Start with `export NAME[=VALUE]...`, then choose only the options needed for the task.

What is a practical export example?

Try `export APP_ENV=production` — Makes APP_ENV available to child commands.

Can I use export in a shell script?

Yes. export works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.