Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

migrated from stackoverflow.com May 3 '11 at 10:31

This question came from our site for professional and enthusiast programmers.

marked as duplicate by slhck Jan 22 '13 at 20:16

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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.

share|improve this answer

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).

share|improve this 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.

share|improve this answer

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...

share|improve this answer

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