A system administrator is analyzing the default permissions for newly created files on a Linux system. A new file `newfile.txt` is created by a user with a `umask` value of `0027`. What will be the octal permissions of `newfile.txt`?
- A660
- B644
- C600
- D640
Show answer & explanationAnswer & explanation
Correct answer: D. 640
For files, the base permissions are typically `666` (rw-rw-rw-). The `umask` value is subtracted from these base permissions to determine the final permissions. For `umask 0027`: `666 - 027 = 640`. (Note: The first digit of umask 0 is for special permissions, which usually doesn't affect file base permissions unless explicitly set.) Therefore, `6 - 0 = 6`, `6 - 0 = 6`, `6 - 2 = 4`, `6 - 7` (which means `6 - (4+2+1)`) is effectively `6 - (4+2) = 0` (no write or execute for others). So, `666 - 0027` results in `rw-r-----` or `640`.
Why the other options are wrong
- A. `660` would be a `umask` of `0007` (666-007 = 660) or `006`, which is not `0027`.
- B. `644` would be a `umask` of `0022` (666-022 = 644), which is not `0027`.
- C. `600` would be a `umask` of `066` (666-066 = 600), which is not `0027`.
Umask Calculation for Files
The `umask` (user file-creation mode mask) determines the default permissions for newly created files and directories.
- For files, base permissions are usually `666` (rw-rw-rw-).
- For directories, base permissions are usually `777` (rwxrwxrwx).
- The `umask` bits are 'subtracted' from the base permissions (more accurately, the inverse of the umask is ANDed with the base permissions).
Memory trick: UMASK: Subtract from 666 (files) or 777 (dirs), then check the math!