Difference between .bashrc and .bash_profile

  • ~/.bash_profile: Read when starting a login shell (e.g., logging in via SSH or certain terminals launched as login shells). Suitable for PATH, environment variables, and one-time initialization logic.
  • ~/.bashrc: Read when starting an interactive non-login shell (e.g., running bash within an existing shell, opening a new terminal tab). Suitable for aliases, functions, command prompts (PS1), and other interactive configurations.