I have been learning about the startup scripts in Ubuntu that get run when you open a new shell: /etc/profile, ~/.bash_profile, ~/.profile, ~/.bash_login
for login shells and
/etc/bash.bashrc, ~/.bashrc
for non-login shells. I have a computer that runs Ubuntu, and the order in which things run on that machine fits that order.
However, the files and the order they run in seems different for MacOS. I see that there is /etc/bash
instead of /etc/bash.bashrc
. In the home directory, I don't see ~/.profile
or ~/.bash_login
. Weirdest of all, when I put echo statements in all of these files, I see that I'm hitting both /etc/profile
and /etc/bash
whenever I open Terminal.app. Shouldn't I only hit the first one, seeing as I'm in a login shell? See below, the first three lines are my echo statements, and the fourth is me confirming that I'm in a login shell:
In /etc/profile
In /etc/bashrc
In ~/.bash_profile for user: davidkennell
Davids-MacBook-Pro:~ davidkennell$ shopt login_shell
login_shell on
So far, I'm coming to the conclusion that the shell startup scripts for Mac are simply completely different from Ubuntu, despite both of them being Unix-based. Where can I get some info on which files are run when initializing login/non-login shells on Mac, and in what order?