Pcornel
Automation · Bash Automation

Environment Variables

Cheat sheet · https://pcornel.dk/topic.php?topic=5288

Back to the Topic

Answer

Environment variables in Bash are exported variables passed to child processes, such as PATH or HOME. Set them with export NAME=value, and remember cron and systemd start with a minimal environment.

Remember

  • export passes variables to child processes.
  • cron and systemd start with minimal environment.
  • Set PATH explicitly in scripts.

First checks

  • printenv | sort — environment
  • env -i bash --noprofile --norc -c 'printenv' — minimal env (cron-like)
  • export VAR=value — export

Verify in this order

parent env → exported vars → child processes

Where it usually breaks

Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5288

Confirmation

Confirm action

Continue?