How to Set Environment Variables in Linux (export)
export makes a shell variable available to any programs launched from that shell, not just the shell itself.
Published October 1, 2026
export makes a shell variable available to any programs launched from that shell, not just the shell itself.
Key points
- export API_KEY=abc123 sets the variable for the current session and any commands run from it
- Add export statements to a shell config file (~/.bashrc, ~/.zshrc) to persist them across sessions
- echo $API_KEY displays the current value of a variable
Example
export NODE_ENV=production