Which Bash File Am I Even Using? Troubleshooting Bash Source Files


If you’ve ever battled various bash profiles to see which one is being used or over ridden, here’s a quick way to troubleshoot.

Note: You can find out what shell you’re using by entering: echo $SHELL in your terminal.

Let’s say we have two bash files, ~/.bash_profile and ~/.bashrc, but you’re not sure which is actually being sourced. Sometimes the ~/.bash_profile references the ~/.bashrc and ~/.bashrc is where everything is being defined.

To start troubleshooting, update your files with the following:


export MYBASH="bash_profile"



export MYBASH="bashrc"

Then in your terminal: echo $MYBASH

This should give you a starting point for identifying which file is actually being sourced.

Inspired by StackExhange Post