LX0-103 · Question #120
You want the default permissions for your files to bE.rw-r-. How must you set umask?
The correct answer is A. 037. Umask 037 masks write and execute from group and all bits from others, producing permissions of rw-r----- (640) when applied to the default file creation mode of 0666.
Question
You want the default permissions for your files to bE.rw-r-. How must you set umask?
Options
- A037
- B640
- C038
- D027
How the community answered
(53 responses)- A79% (42)
- B13% (7)
- C6% (3)
- D2% (1)
Why each option
Umask 037 masks write and execute from group and all bits from others, producing permissions of rw-r----- (640) when applied to the default file creation mode of 0666.
A umask of 037 has a group mask of 3 (binary 011, blocking write and execute) and an other mask of 7 (binary 111, blocking all permissions). When bitwise AND-ed with the complement of 037, the default file mode 0666 (rw-rw-rw-) becomes 0640 (rw-r-----). Because files are never created with execute bits by default, masking execute from the group still results in read-only group access, matching the desired output.
640 is the target permission value itself, not a umask - umask specifies which bits to remove from the default mode, so setting umask to 640 would strip nearly all permissions from new files.
038 contains the digit 8, which is outside the valid range for octal notation (digits 0-7 only), making this an invalid umask value.
Umask 027 masks only the write bit (2) from group rather than write and execute (3), which also produces 640 for files but leaves the group execute bit unmasked for directory creation where the default mode is 0777, making it less restrictive than 037.
Concept tested: umask calculation for target file permissions
Source: https://linux.die.net/man/2/umask
Topics
Community Discussion
No community discussion yet for this question.