101-500 practice question 12 of 30

Which of the following settings for umask ensures that new files have the default permissions -rw-r--- -- ?

Full set: 246 questions
Answer options
A: 0017
B: 0640
C: 0038
D: 0027 Correct answer
Correct Answer:
D. 0027
Explanation

The umask value is a bitmask that removes permissions from the default creation modes. For files, the default mode is 666 (rw-rw-rw-). The desired permission is 640 (rw-r-----). To achieve this, the umask must remove the write permission for the group (020) and all permissions for others (007). Adding these together gives a mask of 027. Applying this mask (666 AND NOT 027) results in 640.

Why Incorrect

A. A umask of 0017 would result in file permissions of 660 (rw-rw----), not 640.
B. 0640 is a permission mode, not a typical umask value. If used as a mask, it would result in permissions of 026 (----w-rw-).
C. 0038 is not a valid octal number because the digit 8 is not part of the octal system (0-7).

References

- umask(2) Linux manual page. It describes umask() as setting the calling process's file mode creation mask.

- Red Hat Enterprise Linux 8 Documentation, "Configuring basic system settings", Chapter 10, "Controlling access to files with umask". This chapter details how the umask value is used to determine default file and directory permissions.

- Shotts, W. (2019). The Linux Command Line. No Starch Press. Chapter 7, "Permissions", explains the concept of umask and how to calculate resulting permissions.

Scroll to Top