The initialization of bash is different when it is started from login event or started as a shell after login.
When user login, Linux starts a shell based on configuration in /etc/passwd specified by admin. If it is a bash shell, the command in /etc/profile will firstly be applied, then followed by all the script suffixed with .sh in /etc/profile.d. The latter allow maintaining local customization to /etc/profile which may be replaced during upgrade. Then .bach
-profile, .bash_login or .profile file in the user's home directory is executed to allow personalization. When user log off, .bash_logout file will run to clean up like temp files.
When bash is invoked not from login, it will not run those files above. Instead, it runs .bashrc in the user's home directory to initialize. .bashrc usually call /etc/bashrc.
When bash is invoked in non-interactive mode (e.g. execute a script), none of the start up files above will be run. The shell will only inherit the environment variables from its parent shell.