How to set the file creation UMASK

The umask setting controls the default permissions for files created by users.

I like to set the umask so that by default files are only readable by their owner.

Set the umask in /etc/profile:

# umask 022
umask 077

Set the umask in /etc/login.defs:

# 022 is the "historical" value in Debian for UMASK when it was used
# 027, or even 077, could be considered better for privacy
# There is no One True Answer here : each sysadmin must make up his/her
# mind.
#UMASK          022
UMASK           077

Set the umask in /root/.bashrc:

# umask 022
umask 077