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
Machine-checked — no person has signed for it. This question was read against the source cited below by an automated pass, which found no contradiction. That is a weaker claim than it sounds: the same kind of process wrote the question, so it can confirm its own mistake.
Treat it as a good draft rather than as settled fact, and read the source below before you rely on it. It is not used in mock exams here — only questions a person has signed for are.
How these questions are written — where each question comes from, what the verification ledger records, and what happens when one is found wrong.
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 short set from objective 104 and space the ones you get wrong.
More questions on this objective
- A new disk /dev/sdb has no partition table at all. Which command writes an empty GPT partition table onto it without dropping you into an interactive editor? machine-checked
- You need the partition /dev/sdc1 on a USB stick to carry a FAT32 filesystem so that Windows machines can read and write it. Which command creates it? machine-checked
- You have just run `mkswap /dev/sdb2`. Which command makes the kernel start using that swap area immediately, without a reboot? machine-checked
- Why is it dangerous to run e2fsck against an ext4 filesystem that is currently mounted read-write? machine-checked
- On an ext4 filesystem at /dev/sda1 you want an automatic check to be forced after every 30 mounts. Which command sets that? machine-checked
- `df -h /var` reports the filesystem 100% full, but `du -sh /var` accounts for only about half that space. Nothing is hidden under a mount point. What is the most likely explanation? machine-checked
All questions on Devices, Linux filesystems, filesystem hierarchy standard