Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

From System-wide environment variables:

  • /etc/environment - This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide locale and path settings.

I'm looking for an ABNF and/or a more detailed description of behaviour, or anything that isn't forum hearsay really.

If it's on Google, it's eluding me.

share|improve this question
up vote 9 down vote accepted

I'm not sure why this isn't made more clear, but /etc/environment isn't parsed by any single bit of code or any particular shell (or necessarily any shell at all) (try grep -r "/etc/environment" /etc and you'll see what I mean). pam in particular parses it directly, not putting it through a shell.

By convention, and I do mean convention, it's pure key-value pairs, with values optionally quoted. You can't put anything that tries to do e.g. variable expansion or command execution in there and expect it to work.

I'd be surprised if you can find a strict, formal grammar definition anywhere.

Probably the closest to an authoritative answer you can come is the pam_env docs:

share|improve this answer

You can find good information in the environ man page. It is accessible from a terminal, by typing man 7 environ in it.

By convention the strings in environ have the form "name=value".

You can also read it from your browser:

And it gives you some examples of usage and more details.

share|improve this answer
Note that the environ(7) man page documents the format of the environment of a process, in the C API. The file /etc/environment is used to fill the environment of a process, but it has its own syntactic rules, as explained by Nicholas. – Gilles Aug 13 '10 at 8:24

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.