Server Fault is a question and answer site for system and network administrators. 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

I'm trying to introduce a variable and add it to the global path in ubuntu 10.04. According to the official docs, /etc/environment is the right place. Here's what my example looks like:


The GRADLE_HOME variable is added to the environment, but it's not interpreting the $GRADLE_HOME variable during the PATH assignment. Hard-coding it works fine. Not a big deal, but I'd like to know if variable substitution is supported, or if there's a better way to do this? Thanks!

share|improve this question
up vote 4 down vote accepted

This explanation from a related post appears to provide the answer:

Because /etc/environment is not a shell script. It is the shell that does expansion of environment variables. The PAM module pam_env is what reads /etc/environment - and it treats it as a simple list of KEY=VAL pairs and sets up the environment accordingly. It has no language for doing variable expansion.

share|improve this answer
so, in short, just use /etc/profile :) – Filipe Pina Feb 1 '12 at 20:07
No, it just means variable substitution doesn't work when editing the global profile. /etc/profile is a per-user environment location. sometimes you really do want to edit the global environment settings. – Dan Feb 1 '12 at 23:24
/etc/profile is per-user...? A per-user file in /etc? Last time I checked /etc/profile is the system-wide ~/.profile. ~/.profile is the per-user location. – Filipe Pina Feb 6 '12 at 20:08
Sorry - misread your comment. I think /etc/profile is just for interactive shells, and I needed to handle non-interactive shells as well. – Dan Feb 6 '12 at 23:31

Read the pam_env.conf(5) manpage.

I believe you need to add curly-braces around the variable name on the right-hand side:


(Possibly non-existent) environment variables may be used in values using the ${string} syntax and (possibly non-existent) PAM_ITEMs may be used in values using the @{string} syntax. Both the $ and @ characters can be backslash escaped to be used as literal values values can be delimited with "", escaped " not supported. Note that many environment variables that you would like to use may not be set by the time the module is called. For example, HOME is used below several times, but many PAM applications don´t make it available by the time you need it.

share|improve this answer
Thanks, but this didn't work in my environment (10.04 32-bit server). Same effect, where it seems to treat the value as a literal. – Dan Jul 30 '10 at 14:58
I also tried this and it did not work. – benmccann Mar 27 '11 at 18:53

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.