Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. 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 the lfs doc:

The exec env -i.../bin/bash command in the .bash_profile replaces the running shell with a new one with a completely empty environment, except for the HOME, TERM, and PS1 variables. This ensures that no unwanted and potentially hazardous environment variables from the host system leak into the build environment. The technique used here achieves the goal of ensuring a clean environment.

What case will cause that problem?

Is there any simple example?

share|improve this question
up vote 1 down vote accepted

There are plenty of variables which will change how the shell behaves, what programs are executed or can hook into new programs. Examples for some of the more problematic environment variables are CDPATH, LD_LIBRARY_PATH, LD_PRELOAD, PATH.

By resetting the environment you can ensure a clean and sane build environment without the need to take care/reset all kind of environment variables.

share|improve this answer
What you mean 'hook into new programs like CDPATH, LD_LIBRARY_PATH, LD_PRELOAD, PATH'? Thank you~ – sam Jul 25 '12 at 16:20
@sam as i said environment variables can control many things, like which shared libraries are loaded or which program gets executed if you are using an unqualified command etc. i'll rephrase that sentence – Ulrich Dangel Jul 25 '12 at 16: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.