Bash profile vs bashrc vs profile

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.

Last Updated: 2023-03-28

My bash install has .profile file and a .bash_profile. These are both "profile" files and they are used for login/interactive shells. First /etc/profile gets loaded, then either .profile or .bash_profile (only one of these: preference for later one)

That said, in general the .bash_profile should source the .profile so its commands will be included anyway

By contrast, .bashrc is executed for interactive non-login shells.

FYI Zsh runs ~/.zprofile, not ~/.profile, when it is invoked as a login shell