Lexicon
⌘K
Explore
ExploreGuidesNotes
WriteMy LibraryBooks
Sign in
Browse

Bug Bounty

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

Databases

  • Database indexing basics

DevOps

  • How environment variables work

Discussions

  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • TCP somethin
  • What's the tcp ip

Git

  • Git commands I use every day

JavaScript

  • JavaScript async and await

Kotlin

  • Kotlin coroutines overview

Linux

  • Useful Linux filesystem commands

Performance

  • How caching improves application performance

React

  • React component design principles

Reference

  • Markdown formatting reference

Software Craft

  • Clean code naming practices
  • Debugging checklist

SQL

  • SQL joins explained

Swift

  • SwiftUI state management

Web

  • API pagination patterns
  • Understanding HTTP status codes
New noteSuggest a guide

Lexicon

a personal knowledge base

← Back to note

Version history

No earlier versions yet — history builds up each time this note is edited.

Current version1 of 1

DevOps

How environment variables work

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 .env.example with blank or dummy values so teammates know which keys to set.

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.