Command referenceexport
export command (Linux / bash / sh / zsh)
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 / option | Meaning |
|---|---|
| NAME=VALUE | Assign and export a value. |
| -p | List exported variables in reusable form. |
| -n NAME | Remove 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.
Related commands
- echoWrite arguments and shell-expanded values to standard output.
- whichLocate the executable selected from the current PATH.
- setDisplay, create, or remove CMD environment variables.
- systemctlControl and inspect services and other systemd units.
- Get-ServiceRetrieve service controller objects and current service states.
- shutdownShut down, restart, sign out, or schedule power actions.
- dateDisplay or format the system date and time.
- journalctlQuery and follow logs stored by the systemd journal.
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.