010-160 File Permissions and Ownership 4 — Questions and Answers
Question 1: What does 'chmod g-w file.txt' do?
- Removes write permission from the group (Correct answer)
- Adds write permission to the group
- Removes write permission from all users
- Sets group permission to write only
Correct answer: Removes write permission from the group
The minus sign in symbolic notation removes the specified permission; g-w removes write from the group.
Question 2: A new file is created while umask is 0027. What are the resulting file permissions?
- 640 (rw-r-----) (Correct answer)
- 750 (rwxr-x---)
- 644 (rw-r--r--)
- 600 (rw-------)
Correct answer: 640 (rw-r-----)
Files start at 0666; 0666 - 0027 = 0640, which is rw-r-----.
Question 3: Which command shows the numeric (octal) permissions of a file?
- stat file.txt (Correct answer)
- ls -l file.txt
- chmod file.txt
- file file.txt
Correct answer: stat file.txt
The stat command displays detailed file information including octal permissions.
Question 4: What does SGID do when set on a directory?
- New files in the directory inherit the directory's group (Correct answer)
- New files run as the directory's group owner
- Prevents non-group members from reading files
- Gives group members root access
Correct answer: New files in the directory inherit the directory's group
SGID on a directory causes newly created files to inherit the directory's group instead of the creator's primary group.
Question 5: User 'root' owns a file with permissions ----------. Can root read the file?
- Yes, root bypasses permission checks (Correct answer)
- No, root has no permissions on this file
- Only if root is in the file's group
- Only with sudo
Correct answer: Yes, root bypasses permission checks
Root (UID 0) bypasses DAC permission checks and can read, write, and execute any file.
Question 6: Which permission string indicates a directory with SGID set and execute permission for all?
- drwxr-sr-x (Correct answer)
- drwxr-xr-x
- drwxr-Sr-x
- drwsr-xr-x
Correct answer: drwxr-sr-x
Lowercase 's' in the group execute position (drwxr-sr-x) means SGID is set and execute is enabled for the group.
Question 7: What happens when you use 'chmod = r file.txt' (symbolic assignment)?
- Sets read permission for all; clears write and execute for all (Correct answer)
- Adds read permission without changing others
- Removes read permission for all
- Sets file to read-only for the owner only
Correct answer: Sets read permission for all; clears write and execute for all
Using '=' with no class prefix applies to all classes and sets exactly those permissions, clearing all others.
What does 'chmod g-w file.txt' do?