Default permissions and umask
Quick answer
umask is a file-creation mask, not a permission grant. It removes bits from the mode requested by a program when a new file or directory is created.
Prepare the practice environment
Use the chapter fixture described in lab-fixtures/permissions/README.md. Run setup as a normal user in a disposable Linux environment, enter the printed directory, check pwd, and run export LC_ALL=C; umask 022. Every example assumes a fresh fixture. Commands omit the terminal prompt; outputs below are not commands.
How it works
Without a default ACL, the result is requested mode AND NOT mask. Typical ordinary files request 0666, directories 0777. With 0027 these become 0640 and 0750. This is bit removal, not general arithmetic subtraction. Existing files are unchanged, and programs may request stricter modes. A parent default ACL changes the normal creation algorithm. Bash umask affects the current shell and its future children; parentheses create a subshell so the lab mask does not persist in your interactive shell.
For example, 0666 with mask 0111 stays 0666: none of the execute bits were requested in the first place. A program that requests 0600 cannot obtain group permissions merely by using mask 000. Compare a new file with an existing file to distinguish creation policy from an explicit chmod change.
Try the examples
0666 with the mask bits cleared becomes 0640.
Expected stdout:
6400777 with the mask bits cleared becomes 0750.
Expected stdout:
750(umask 077; touch report.txt; stat -c %a report.txt)touch updates timestamps on the existing file; umask does not change its mode.
Expected stdout:
640Common mistakes
Never calculate all masks by subtraction or assume umask retroactively protects files. Verify a newly created file and consider default ACLs.
Practice
Use umask 077 in a subshell to create a fresh ordinary file and directory. Predict and verify 600 and 700.
Related references
Study: umask, stat. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Default permissions and umask — Knowledge Check
Apply the lesson concepts to the controlled permission fixture.
What is the normal file mode for 0666 and mask 027?
What is the usual directory mode for 0777 and mask 077?
Does changing umask change existing file modes?
What can alter this simple creation rule?