Lexicon
⌘K
Explore
ExploreGuidesNotes
WriteMy Library
Sign in
Browse

Networking

  • OSI Model
  • TCP vs UDP
  • TCP/IP Model
  • Layer 2 & Layer 3 Networking

Programming

  • Start Here — How to Solve a Problem
  • From if/else to DSA — The Whole Path
  • Problem Solving
  • DSA Practice — Learn by Solving
  • C Programming
  • Python

Bug Bounty

  • Only Bug Bounty Checklist You'll Ever Need!!!
  • Only Bug Bounty Checklist You'll Ever Need!!! V2

My Notes

  • Python Conditional Statements - The Complete Breakdown
  • Python Data Types - The Complete Breakdown
  • Python Dictionaries - The Complete Breakdown
  • Python Exception Handling - The Complete Breakdown
  • Python Functions - The Complete Breakdown
  • Python Lists vs Arrays — The Real Story
  • Python Loops - The Complete Breakdown
  • Python OOP - The Complete Breakdown
  • The f Thing in Python - f-strings

Python

  • Python String Manipulation Functions - Full Reference
New noteSuggest a guide

Lexicon

a personal knowledge base

DevOps

How environment variables work

scorpionxdevUpdated 6/12/2026 · 1 min read · 0 views
PDFHistory

Environment variables are named values that live in a process and get inherited by the processes it spawns. They are the standard way to pass configuration and secrets into an app without hardcoding them.

Setting and reading them

export API_URL=https://api.example.com
echo $API_URL
printenv | sort          # list everything in the current environment

Set one just for a single command by prefixing it:

NODE_ENV=production node server.js

Inheritance

A child process inherits a copy of its parent's environment. Changing a variable in the child does not affect the parent, and a variable set without export is not passed down at all.

Reading them in code

const url = process.env.API_URL;
if (!url) throw new Error('API_URL is not set');
import os
url = os.environ.get('API_URL', 'http://localhost:3000')  # with a default

The .env pattern

For local development, keep values in a .env file and load them with a library like dotenv. Never commit that file.

# .env
DATABASE_URL=postgres://localhost/dev
SESSION_SECRET=change-me

Add it to .gitignore and commit a with blank or dummy values so teammates know which keys to set.

Reading progress0%
scorpionxdev@scorpionxdev
.env.example

Secrets are not really hidden

Anyone who can run printenv in your process, or read your deployment config, can see them. Env vars keep secrets out of source control, not out of a compromised machine. For production, use a real secrets manager.

0 comments

Sign in to join the discussion.