Various ways to set environment variables in Ubuntu

It came to me as a surprise that recent Ubuntu versions store user-level locale selection (i.e. LC_* variables) in $HOME/.pam_environment. Eg. if you set some LC_* variable in your shell config (eg. $HOME/.profile), chances are that the contents of your .pam_environment file will override it for most GUI apps.

There a number of config files that Ubuntu uses for environment and/or locale variables:
  1. /etc/environment: this contains system-wide defaults and this is read first
  2. /etc/default/locale: this contains system-wide locale (LC_*) defaults and this is read second
  3. $HOME/.pam_environment: this contains user-level variables and is read third
  4. /etc/*[code]: various system-wide shell config files (eg. [code]profile, zsh/zshenv, zsh/zprofile, etc.)
  5. $HOME/.*: various user-level shell config files (eg. [code].profile, .zshenv, .zprofile, etc.)