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

May 14, 2020 min read

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:

~/.bash_profile

export MYBASH="bash_profile"

AND

~/.bashrc

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