010-160 File Permissions and Ownership 3 — Questions and Answers
Question 1: What permission is needed to list the contents of a directory?
- Read (r) (Correct answer)
- Execute (x)
- Write (w)
- Both read and execute
Correct answer: Read (r)
Read permission on a directory allows listing its contents with ls.
Question 2: Which command recursively changes ownership of /var/www to user 'www-data'?
- chown -R www-data /var/www (Correct answer)
- chown www-data -r /var/www
- chmod -R www-data /var/www
- chgrp -R www-data /var/www
Correct answer: chown -R www-data /var/www
chown -R applies the ownership change recursively to all files and subdirectories.
Question 3: What does the SUID bit do when set on an executable file?
- Runs the file with the owner's privileges (Correct answer)
- Runs the file with the group's privileges
- Makes the file read-only
- Prevents the file from being executed by others
Correct answer: Runs the file with the owner's privileges
SUID causes an executable to run with the file owner's effective user ID instead of the caller's.
Question 4: How is the SUID bit represented in ls -l output for a file with execute permission?
- s in the owner execute position (Correct answer)
- S in the owner execute position
- t in the owner execute position
- x in the group execute position
Correct answer: s in the owner execute position
A lowercase 's' in the owner execute position means SUID is set and execute is also set.
Question 5: Which octal value sets the sticky bit on a directory along with permissions 755?
- 1755 (Correct answer)
- 2755
- 4755
- 3755
Correct answer: 1755
The sticky bit is represented by the leading octal digit 1, so 1755 = sticky + rwxr-xr-x.
Question 6: What permission is required to enter (cd into) a directory?
- Execute (x) (Correct answer)
- Read (r)
- Write (w)
- Read and write
Correct answer: Execute (x)
Execute permission on a directory allows users to enter it and access its contents.
Question 7: A user runs 'chmod 600 private.key'. What permissions does this set?
- Owner read and write; no permissions for group or others (Correct answer)
- Owner read only; no permissions for group or others
- Owner full access; group read; others none
- Owner read/write/execute; others none
Correct answer: Owner read and write; no permissions for group or others
600 = rw------- meaning only the owner can read and write; group and others have no permissions.
What permission is needed to list the contents of a directory?