Linux Permissions 4 — Questions and Answers
Question 1: What is the default umask for a regular (non-root) user on most Linux systems?
- 022 (Correct answer)
- 002
- 000
- 077
Correct answer: 022
A umask of 022 is the most common default for regular users, resulting in 644 for files and 755 for directories.
Question 2: Which command grants user 'carol' read and write ACL permissions on report.txt?
- setfacl -m u:carol:rw report.txt (Correct answer)
- getfacl -m u:carol:rw report.txt
- chmod u:carol+rw report.txt
- acl -set carol:rw report.txt
Correct answer: setfacl -m u:carol:rw report.txt
The `setfacl -m u:carol:rw` command modifies the ACL to add or update the named user entry with read and write permissions.
Question 3: If a file has permissions rwSr--r--, what does the uppercase 'S' indicate?
- The setuid bit is set but the owner execute bit is not set (Correct answer)
- The file is a special system file
- The sticky bit is set
- The file is write-protected
Correct answer: The setuid bit is set but the owner execute bit is not set
An uppercase 'S' in the setuid position means the setuid bit is set but the owner does not have execute permission, making it a non-functional setuid.
Question 4: What is the minimum permission a user needs on a directory to create a file inside it?
- Write and execute permissions on the directory (Correct answer)
- Read permission on the directory
- Execute permission only on the directory
- Full rwx on the directory
Correct answer: Write and execute permissions on the directory
Creating a file in a directory requires both write (to add the directory entry) and execute (to traverse the directory) permissions.
Question 5: How do you remove all ACL entries from a file and revert to standard permissions?
- setfacl -b file.txt (Correct answer)
- setfacl -x all file.txt
- getfacl --remove file.txt
- chmod --no-acl file.txt
Correct answer: setfacl -b file.txt
The `setfacl -b` option removes all extended ACL entries, leaving only the base owner/group/other permissions.
Question 6: A new file is created in a directory with the setgid bit set. What group will the file belong to?
- The directory's group (Correct answer)
- The creating user's primary group
- The root group
- The system default group
Correct answer: The directory's group
When the setgid bit is set on a directory, new files created inside inherit the directory's group ownership rather than the creator's primary group.
Question 7: Which symbolic chmod expression removes execute permission from all categories (owner, group, others)?
- chmod a-x file.txt
- chmod -x file.txt
- chmod ugo-x file.txt
- All of the above (Correct answer)
Correct answer: All of the above
All three expressions are equivalent: 'a' means all, omitting the target also defaults to all, and explicitly listing ugo covers all categories.
What is the default umask for a regular (non-root) user on most Linux systems?