Skip to content

environment variable (env var)

An environment variable (env var) is a named value that a running program receives from the system that started it. The program and any programs it launches can read that value at runtime to configure how they behave.

Every process carries its own environment, a set of name-value pairs that the operating system hands down from the parent process that started it.

A child process receives a copy of this set when it is created, so a later change in one process never reaches its parent or its siblings. This copy-on-launch behavior makes the environment a one-way channel for passing settings into a program without altering its command line or its source code.

Launch a child process below, then edit a value in either process to see what the copy carries and what it doesn’t:

Interactive diagram — enable JavaScript to view.

Common uses include the following:

  • Locating resources, as with PATH, the list of directories a shell searches for executables, or HOME, which records the current user’s home directory.
  • Selecting behavior, where a variable such as LANG or TZ switches locale or time zone without any change to code.
  • Passing secrets, supplying values like API keys and database URLs to a program so they stay out of version-controlled files.

A variable can be scoped to a single command, a login session, a user account, or the whole system, and a shell sets one with syntax like export NAME=value. Unix-like systems treat the names as case-sensitive, whereas Windows does not. Python reads the current environment through the os module as the os.environ mapping.

Securely Deploy a Django App With Gunicorn, Nginx, & HTTPS

Tutorial

Securely Deploy a Django App With Gunicorn, Nginx, & HTTPS

Ready to take your Django app beyond development? Learn how to securely deploy your Django web app in production over HTTPS with Gunicorn and Nginx. Along the way, you'll explore how HTTP headers can fortify your app's security.

intermediate django

For additional information on related topics, take a look at the following resources:


By Martin Breuss • Updated Aug. 12, 2026