A user's shell has umask 022. With no other mechanism involved, what permissions does a regular file created by that shell's redirection get?
LPIC-1 Exam 101-500, objective 104. Devices, Linux filesystems, filesystem hierarchy standard medium
Draft — not checked yet. This question was written from the published exam objectives and cites the clause it comes from, but nobody has yet read it against that clause and signed for it.
It is kept out of search results and out of mock exams until they have. Read the source below before you take the answer as settled.
The options
Not correct 666 (rw-rw-rw-)
Wrong. That is the base mode before the umask is applied. It would be the result only with umask 000.
Not correct 755 (rwxr-xr-x)
Wrong for a file, right for a directory. Directories use a base of 777, so 777 minus 022 gives 755. Files never get the execute bit from creation, which is why a fresh script must be chmod'ed.
Correct 644 (rw-r--r--)
Correct. The base mode for a new regular file is 666; the umask bits are removed, and 666 with 022 masked off leaves 644.
Not correct 022 (-w--w----)
Wrong. The umask is not the resulting mode; it is the set of permission bits withheld from the base mode.
Why
umask is subtractive, and it masks bits rather than doing arithmetic: result = base AND NOT umask. Files start from 666, directories from 777. So umask 022 yields 644 and 755, umask 027 yields 640 and 750, and umask 077 yields 600 and 700.
Where this comes from
- Cited
- LPI exam objective 104.5
- What it says
- Use umask to control the default permissions of newly created files and directories.
Practise this
Reading one question is not practice. The trainer will draw a set from objective 104 and space the ones you get wrong.