Skip to main content
>_ supraj.dev
TOPIC LINUX
Environment Variables where config hides
IN 10 SECONDS

Environment variables are key-value pairs stored in the shell process. Sub-processes inherit these variables, making them ideal for passing configuration and secrets.

GOTCHA Variables set without the 'export' keyword are local to the current shell session and will not be inherited by child scripts.
HOW VARIABLE INHERITANCE FLOWS
01 Shell user defines a variable: export DB_HOST='10.0.1.5'.
02 Fork shell spawns a child process (like a web app).
03 Inherit child process copies the environment variables block.
04 Access app reads DB_HOST to establish database connection.
POKE IT YOURSELF
printenv DB_HOST — view the value of a specific environment variable
export DB_PORT=5432 — define and export a variable for child processes