This answer is bash specific, other shells have similar features, but since your answer mentioned
.bashrc I'm going to assume you're using Bash.
What you're encountering is that a shell can either be invoked as an interactive or a login shell.
bash -l - login
bash -i - interactive
If you look in the Bash man page in the "INVOCATION" section you'll notice the following 2 comments:
A login shell is one whose first character of argument zero is a -, or one started with the --login option.
An interactive shell is one started without non-option arguments and
without the -c option whose standard input and error are both connected to
terminals (as determined by isatty(3)), or one started with the -i option.
PS1 is set and $- includes i if bash is interactive, allowing a shell script
or a startup file to test this state.
Interactive & login shells read the config files in the following order. It does this one first:
Followed by one of these (which ever it finds first) in this order:
Interactive shells (that are not a login shell) read an additional config file,
~/.bashrc. Notice that they never read the
/etc/bashrc config file directly. They read it through the
~/.bashrc file because of this stanza:
# Source global definitions
if [ -f /etc/bashrc ]; then
So what about the umask
To get both types of shells to read the
umask you need to include it in one of the files mentioned above that both types of shell invocations will read, so I'd put it in