linux – What is the difference between .bashrc and .bash_profile?


I would like to know what is the difference between the .bashrc and .bash_profile files that usually go in the home of users in Linux or Mac OS operating systems.

If they are the same, can you have only one of those files?

In my case, I only have the .bash_profile file on my home and I need to execute the following command:

echo PATH=\"\$NPM_PACKAGES/bin\:\$PATH\" >> ${HOME}/.bashrc

Would it be the same if I change it to the following?

echo PATH=\"\$NPM_PACKAGES/bin\:\$PATH\" >> ${HOME}/.bash_profile


  • .bash_profile runs only once, when you log in.
  • .bashrc runs every time you start the bash interpreter.

When you run the first command, if the .bashrc file does not exist, it will be created. If it already exists, the line is added to the end.

Due to the purpose of the line you want to add, it is recommended that it be in the .bashrc .

Scroll to Top