nerdexam
CompTIA

LX0-103 · Question #94

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

The correct answer is D. 0027. A umask of 0027 masks group-write and all other-permissions from the default 0666 file mode, producing 0640 (-rw-r-----).

GNU and Unix Commands

Question

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

Options

  • A0017
  • B0640
  • C0038
  • D0027

How the community answered

(44 responses)
  • A
    7% (3)
  • B
    2% (1)
  • C
    18% (8)
  • D
    73% (32)

Why each option

A umask of 0027 masks group-write and all other-permissions from the default 0666 file mode, producing 0640 (-rw-r-----).

A0017

Umask 0017 masks execute for group and all bits for others, producing 0660 (-rw-rw----) from 0666, not 0640.

B0640

0640 is the desired permission value itself, not a umask; using it as a umask would yield nonsensical permissions when applied to the 0666 default.

C0038

0038 contains the digit 8, which is not a valid octal digit, making it an illegal umask value on Linux.

D0027Correct

File permissions are calculated as the default mode (0666) bitwise ANDed with the complement of the umask. With umask 0027 (binary 000 010 111), the complement is 111 101 000; ANDing with 0666 (110 110 110) yields 0640 (110 100 000), which is -rw-r-----. This makes 0027 the only valid umask for that target permission set.

Concept tested: umask calculation for default file permissions

Source: https://man7.org/linux/man-pages/man2/umask.2.html

Topics

#umask#file permissions#octal permissions#permission calculation

Community Discussion

No community discussion yet for this question.

Full LX0-103 Practice