Ad space (banner)
🖥️Linux Lessons
Lesson 32 / 61

Setting Environment Variables with export

export is for when "I want to switch the app's behavior mode, just for this session." export sets an environment variable — a configuration value programs can read.

Use it in the form export variable-name=value. An environment variable set this way becomes readable by every program started from that terminal.

Running export APP_ENV=production sets the environment variable APP_ENV to production, and every program started afterward can read this value.

A common early mistake is not realizing an environment variable set with export disappears the moment you close the terminal. To set it permanently, write it into a config file like .bashrc.

In real work, setting things like API keys or a database connection target as environment variables — switched between production and development — is the standard approach.

Linux
Try it (type this into the pseudo terminal)
export APP_ENV=production

🧑‍💻 You can type this command into the Linux pseudo terminal to try it yourself (this page itself has no interactive terminal).

Ad space (banner)
Ad space (in-article)