2

I changed the /etc/environment to add more directories to the PATH variable. But looks like $PATH in double quotes were not expanded and I could find any command from the shell and /usr/bin/command-not-found is run.

$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
PATH="$PATH:/home/user/technical/java/maven/bin"
JAVA_HOME="/home/user/technical/java/jdk7"

so from the tty,

$ echo $PATH
$PATH:/home/user/technical/java/maven/bin

why did not the expansion happen?

1

/etc/environment is shell agnostic. This means it doesn't depend on the way e.g. bash to any expansion.

You can use only the simple key=value assignments here.

| improve this answer | |
  • which process reads these key pairs? – rag Mar 7 '13 at 21:07
  • e.g. look at grep "/etc/environment" /etc/pam.d/* – H.-Dirk Schmitt Mar 7 '13 at 21:17
  • This answer is not correct - Environment variable does happen unix.stackexchange.com/questions/457054/… I am using Ubuntu and that may work differently, so the answer should clarify that different linux distros may work differently. – ha9u63ar Jul 19 '18 at 8:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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