environment variables

List, read, set and remove environment variables, for a command or for the session.

shell

steps
  1. printenv | sort

    every variable

  2. echo "$HOME"

    one of them

  3. export NAME=value

    set one for this shell and what it starts

  4. NAME=value command

    set one for one command only

  5. unset NAME

    remove one

  6. set -a; source .env; set +a

    load a file of NAME=value lines into the shell

notes
  • To keep a variable, put the export line in ~/.bashrc (or ~/.zshrc).
commands used

printenvexportenv

Each has a page in lore: lore printenv opens it.