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

  • printenv
  • export
  • env

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