You’re invoking it as a login shell there, which explicitly does not source ~/.bashrc
. From the bash man page:
When bash is invoked as an interactive login shell, or as a non-interactive shell with the –login option, it first reads and executes commands from the file /etc/profile , if that file exists. After reading that file, it looks for ~/.bash_profile , ~/.bash_login , and ~/.profile , in that order, and reads and executes commands from the first one that exists and is readable. The –noprofile option may be used when the shell is started to inhibit this behavior.
When an interactive shell that is not a login shell is started, bash reads and executes commands from /etc/bash.bashrc and ~/.bashrc , if these files exist. This may be inhibited by using the –norc option. The –rcfile file option will force bash to read and execute commands from file instead of /etc/bash.bashrc and ~/.bashrc .
Strangely, there are some references to bashrc
in your logs. I suspect they’re loaded by a profile for one reason or another. I’m also not sure if -x
is a good tool for tracing whether bash sourced initial login files, not wholly convinced it’s doing that through commands that will be logged there.
By default the shell that you load into from the TTY is a login shell as well, which is probably what’s confusing you. Some people manually add a Saw the SSH reference, sorry, skimmed past that. No idea why your SSH session isn’t reading bashrc (I forget if those are login shells too, or if you customize that behavior, or what), but your test definitely should not.source ~/.bashrc
to their ~/.bash_profile
, you may have done so previously and forgotten about it. Or you just rarely use the TTY directly, terminal emulators usually run non-login interactive shells.
Bash config always seems trivial until you spin up a new machine