Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

2 Answers 2

up vote 6 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: http://www.linux-pam.org/Linux-PAM-html/sag-pam_env.html

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: http://manpages.ubuntu.com/manpages/lucid/en/man7/environ.7.html#toptoc2

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

share|improve this answer
1  
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

 
discard

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.