Environment Variables
Cheat sheet · https://pcornel.dk/topic.php?topic=2656
Answer
Environment variables are name=value pairs a process passes to its children, such as PATH, HOME, LANG and proxy settings. A variable set in a shell is only exported to child processes with export.
Remember
Each process has its own copy; changing it does not affect running processes. sudo resets most variables (see env_reset). systemd services get only the variables in their unit (Environment=, EnvironmentFile=). Persist user variables in ~/.profile or ~/.bashrc, system-wide in /etc/environment.
First checks
env— current environmentprintenv <NAME>— one variablecat /proc/<pid>/environ | tr '\0' '\n'— environment of a running processsystemctl show <svc> -p Environment— variables set for a servicesudo env— environment under sudo
Commands
systemctl --usersystemctl show <unit> -p Environment
Verify in this order
variable set → exported → inherited by the child process → read by the program
Where it usually breaks
First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2656