Can't set $PS1 properly under Ubuntu 10.04 host

Bruce Dubbs bruce.dubbs at
Thu Jun 3 06:22:35 PDT 2010

littlebat wrote:
> Hi,
> I am learning: 4.4. Setting Up the Environment:
> . My host system is Ubuntu 10.04.
> I found it can't properly to set $PS1 for user "lfs" with the command
> below provided by LFS6.6 book under Ubuntu 10.04 host system.

cat > ~/.bash_profile << "EOF"
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash

> The reason is Ubuntu will setup PS1 in /etc/bash.bashrc, so I think
> maybe we should set this value in ~/.bashrc ?

No, that's not how it works.  Upon login as the lfs user, bash executes


in that order.  The 'exec env -i' portion ignores the environment that 
was set by /etc/profile.  The second part sets up 3 and only 3 
environment variables.  bash itself sets up a few more, but not PS1.
$HOME/.bashrc is not run by default in an initial login.

Make sure you are doing an initial login.

su - lfs

The dash is important.  Without it, $HOME/.bash_profile is not run and 
only $HOME/.bashrc is run.

Other sub-shells that are run by the lfs user do use $HOME/.bashrc

Take a look at the invocation portion of the bash man page and also at 
the env man page.

   -- Bruce

More information about the lfs-support mailing list