Possible Duplicate:
Difference between .bashrc and .bash_profile

What's the difference between .profile and .bash_profile, and when do you configure which?

I.e if I configure the .bash_profile, do I still need to configure .profile?


4 Answers 4


Assuming bash is your default shell, the differences are described in the bash man page (man bash):

   When bash is invoked as an interactive login shell, or as  a  non-interac-
   tive  shell  with the --login option, it first reads and executes commands
   from the file /etc/profile, if that file exists.  After reading that file,
   it  looks  for  ~/.bash_profile,  ~/.bash_login,  and  ~/.profile, in that
   order, and reads and executes commands from the first one that exists  and
   is readable.  The --noprofile option may be used when the shell is started
   to inhibit this behavior.

There is more detail in the man page that covers POSIX-shell compatibility mode, which is where .profile comes from. Read the whole man page section for all the details.

  • in Ubuntu 18.04 opening an new Terminal window does not call .profile only .bashrc :(
    – CpILL
    Aug 9, 2019 at 1:00
  • To clarify, "reads and executes commands from the first one that exists", means it only runs the first of the 3 files it finds (so if all 3 existed, it would only run ~/.bash_profile, which was not obvious to me (I assumed it would run all three).
    – stevec
    May 31, 2020 at 5:07

If you configure .bash_profile, you won't also need to configure .profile.

I like to keep my own aliases and commands in .profile so that if I mess up anything, I know that I can always delete the .profile without affecting the system at large or other applications that modify .bash_profile (like MacPorts).

To use a .profile, you may need to include the line source ~/.profile in your .bash_profile so that the .profile file is read (see Ned Deily's answer).


.profile is executed by bash when you get a normal shell process -- e.g. you open a terminal tool. .bash_profile is executed by bash for login shells -- so this is when you telnet/ssh into your machine remotely for instance. For instance if you ssh remotely into a machine (let's say you open an X Terminal) you will get initially .bash_profile executed. If in that XTerminal you type "xterm" and spawn another X Terminal, then .profile will be executed for the second instance of XTerminal. The files reside in your home directory (~). If I'm not mistaking by default they both execute ~/.bashrc so you can edit that to configure common settings/variables for both login and non login shells (e.g setting PATH, some aliases/shortcuts etc). You might want occasionally to configure certain things differently for these 2 but I have never encountered that need -- however, the possibility is there.

  • in Ubuntu 18.04 opening an new Terminal window does not call .profile?
    – CpILL
    Aug 9, 2019 at 0:59

for the fast and simple config (where you don't want complicate things) simply configure everything in your ~/.profile. Only when you run into some troubles (but probably will never) learn more about the .bash_login or .bash_profile ;)

I'm on OS X too, and never needed .bash_profile or .bash_login and using only .profile, but your mileage may vary...

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