Recently I was working on an issue where an application was not retaining the umask setting set in the root users profile or /etc/profile. After looking into the issue a bit it seemed that the application in question only applied the umask setting that was set in /etc/bashrc and would not even accept the values being the applications own start scripts.
After doing a bit of researched I learned a little bit more about what exactly these files do, the differences between them and when they are executed. I figured this would be a good thing to share as it is not a topic that comes up very often.
Use of /etc/profile file
The /etc/profile file contains system wide environment variables on users shells. All customizations that you put in this file will apply for the entire environment variable on your system.
On the off chance that you have been using Linux for some time you are probably familiar with the .profile or .bash_profile files in your home directory. These files are used to set environmental things for a user shell. Things, for example, umask, and variables, for example, PS1 or PATH.
Use of /etc/profile.d
In addition to the setting environmental things the /etc/profile will execute the scripts inside /etc/profile.d/*.sh. On the off chance that you plan setting your own system wide environmental variables it is prescribed to put your configuration in a shell script inside /etc/profile.d.
Use of /etc/bashrc file
Like .bash_profile you will also commonly see a .bashrc file in your home directory. This file is meant for setting command aliases and functions used by bash shell users.
Just like the /etc/profile is the system wide version of .bash_profile. The /etc/bashrc for Red Hat and /etc/bash.bashrc in Ubuntu is the system wide version of .bashrc.
Interestingly enough in the Red Hat implementation the /etc/bashrc also executes the shell scripts within /etc/profile.d but only if the users shell is a Interactive Shell (aka Login Shell)