Unexpected file modes can expose new files to other users or stop a shared group from editing new project content. In Linux, the umask value removes permission bits from newly created files and directories before they appear on disk.
The mask belongs to a process. Shells set it, and commands started from that shell inherit it. A mask of 027 commonly creates files as 640 and directories as 750, while 022 creates readable-by-everyone defaults and 002 keeps group write access for collaborative directories.
The change affects only objects created after the mask is set. Existing modes need chmod, systemd services can use a unit-level UMask= setting, and a directory default ACL can change creation modes inside that directory.
$ umask 0022
Use 027 for owner read/write, group read-only, and no other access in the common file case. Use 077 for private files, 022 for owner-write and world-readable defaults, or 002 when a shared group should keep write access.
$ umask 027
This change applies to commands started from this shell. It does not rewrite existing file modes.
$ umask 0027
With Bash, umask -S can show the same mask symbolically, such as u=rwx,g=rx,o=.
$ touch report.txt
$ mkdir project-dir
$ stat --format="%A %a %n" report.txt project-dir -rw-r----- 640 report.txt drwxr-x--- 750 project-dir
Regular files normally start from a maximum of 666 before the mask is applied, so umask cannot add execute permission to a new file created by touch.
$ rm -r report.txt project-dir
$ vi ~/.profile
Use the startup file that your login path actually reads, such as ~/.profile for POSIX-style login shells or ~/.bashrc for interactive Bash shells on systems that source it.
umask 027
$ bash --login
$ umask 0027
Do not set a broad mask such as 000 on multi-user systems unless the account is intentionally creating world-writable content. Services launched outside the login shell may need their own service manager setting.