Setting env. variables manually

Gunnar Hjalmarsson gunnarhj at ubuntu.com
Fri Dec 13 04:59:27 UTC 2013


The advices at https://help.ubuntu.com/community/EnvironmentVariables on
how to manually set environment variables have resulted in some
confusion, some of which you can read about in various forums.

The page recommends that these files are used for the purpose:

  ~/.pam_environment
  /etc/environment
  /etc/default/locale

Personally I don't find any of them optimal. As regards
~/.pam_environment and /etc/default/locale, they are written to
automatically when people set their languages and locales via the GUIs,
so there is a risk that manual entries are accidentally overwritten.
Also, the files are not script files, and the syntax required by PAM is
not very well known.

I tend to think that these files are preferred when you need to
manipulate environment variables manually:

  ~/.profile    - for user specific settings
  /etc/profile  - for system wide settings

They are both sourced by the login managers. Since that happens after
PAM has read the environment, you can also use them for overriding
individual variables set by the language/locale GUIs.

I'm about to edit
https://help.ubuntu.com/community/EnvironmentVariables, but before doing
so, and since this is an area where established practice should be taken
into consideration, I'd appreciate some input here before doing so.

-- 
Gunnar Hjalmarsson
https://launchpad.net/~gunnarhj



More information about the ubuntu-devel mailing list