Set umask to 027.
A normal program creates a regular file with the usual requested mode 666.
What mode is normally created?
Remove the masked bits from the regular-file base mode 666. With umask 027, the result is 640.
Detailed explanation
640Correct. 0666 with umask 0027 produces 0640.
Correct. 0666 with umask 0027 produces 0640.
650Incorrect. 0650 does not follow the bitwise masking result.
Incorrect. 0650 does not follow the bitwise masking result.
666Incorrect. 666 is the requested mode before umask is applied.
Incorrect. 666 is the requested mode before umask is applied.
027Incorrect. The umask value is not the resulting file mode.
Incorrect. The umask value is not the resulting file mode.
Try it yourself
An example you can run in a temporary verification environment.
tmp=$(mktemp -d); (umask 027; : >"$tmp/file"); stat -c '%a' "$tmp/file"; rm -rf "$tmp"Expected result
640Key points
- File base mode is 666
- umask removes bits
- 027 masks group write and other permissions
Notes
- Environment: POSIX shell / GNU stat
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.