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:

/etc/environment: this contains system-wide defaults and this is read first

/etc/default/locale: this contains system-wide locale (LC_*) defaults and this is read second

$HOME/.pam_environment: this contains user-level variables and is read third