I set .bash_profile to

 exec env -i HOME=$HOME TERM=vt100 PS1='\h' /bin/bash

But when I login, it also show:

 lfs@sam:~$ env

What happened?

How to set PS1 when login?

Thank you~

  • 2
    PS1 is usually set in .bashrc, not .bash_profile. .profile type files are for setting environment variables. PS1 is a shell variable, not an environment variable. Chances are, you have a .bashrc that is also setting PS1.
    – jw013
    Commented Jul 25, 2012 at 16:41

1 Answer 1


This value of PS1 is set by the bash system-wide configuration file /etc/bash.bashrc. You can override it by setting it from your ~/.bashrc.

PS1 is a shell variable. Its meaning depends on the shell. It should normally not be exported since it is not supposed to be in process's environments, though you can get away with it if you only ever use one shell.

Note that bash is rather quirky about configuration files: if you start a login instance of bash, it reads only /etc/profile and ~/.bash_profile, and ~/.profile if there is no ~/.bash_profile. If you start a non-login interactive instance, it reads /etc/bash.bashrc (if configured to do so) and ~/.bashrc. In order to get your interactive settings in login instances of bash, you should put this code in your ~/.bash_profile:

if [ -r ~/.profile ]; then
  . ~/.profile
case $- in *i*) if [ -r ~/.bashrc ]; then . ~/.bashrc; fi;; esac

The shell variable $- contains the letter i to indicate that the shell is interactive.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .