Ubuntu – find documentation on the /etc/environment file format

environment-variables

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.

Best Answer

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