1. Directory Access
What access does user bob have on abc.txt?
drwxr-xr-x. 17 root root 4096 23:38 /
drwxr-xr--. 10 root root 128 03:38 /data
-rwxr-xr--. 1 bob bob 100 21:08 /data/abc.txt
Answer : None
Explanation
- File permissions suggest bob has full access (
rwx) toabc.txt. - But to access a file, the user must have execute (
x) permission on all parent directories. - On
/data, bob has others permissions:r--. -
Without execute (
x) on/data, bob:- Cannot
cdinto the directory - Cannot access, read, write, or execute the file
- Cannot
Lesson Learned
Always check parent directory permissions before file permissions. File permissions only apply after directory access is allowed.
2. Viewing Directory Contents
Who can use ls /data to display the contents of the /data directory?
drwxr-xr-x. 17 root root 4096 23:38 /
drwxr-xr--. 10 root root 128 03:38 /data
-rwxr-xr--. 1 bob bob 100 21:08 /data/abc.txt
Answer : All users
Explanation
- To list directory contents, a user needs read (
r) permission on the directory. -
All users have:
- Execute (
x) on/→ can traverse to/data - Read (
r) on/data→ can runls /data
- Execute (
-
Therefore, any user can view the directory contents, including hidden files (
ls -a).
Lesson Learned
Read (
r) permission allows listing directory contents. Execute (x) permission is required for detailed access.
3. Deleting Directory Contents
Who can delete the file /data/abc.txt?
drwxr-xr-x. 17 root root 4096 23:38 /
drwxrw-rw-. 10 root root 128 03:38 /data
-rwxr-xr--. 1 bob bob 100 21:08 /data/abc.txt
Answer : Only the root user
Explanation
- File permissions do NOT control deletion.
-
To delete a file, a user needs:
- Write (
w) permission on the directory - Execute (
x) permission on the directory
- Write (
-
Although everyone has write (
w) on/data,- Only root has execute (
x) on/data.
- Only root has execute (
-
Without execute permission, users cannot access the directory to remove files.
Lesson Learned
Write (
w) allows file deletion only when execute (x) is also present on the directory.
4. Accessing the Contents of a Directory
True or False: Can user bob successfully run more /data/abc.txt?
drwxr-xr-x. 17 root root 4096 23:38 /
dr-xr-x--x. 10 root root 128 03:38 /data
-rwxr-xr--. 1 bob bob 100 21:08 /data/abc.txt
Answer : True
Explanation
-
To access a file, a user needs:
- Execute (
x) permission on all parent directories - Read (
r) permission on the file
- Execute (
-
The read (
r) permission on the directory is NOT required to access a known file. -
User bob has:
xon/xon/dataron/data/abc.txt
-
Therefore, the command executes successfully.
Lesson Learned
Execute (
x) allows entering a directory; read (r) on the directory is only needed to list files.
5. The Complexity of Users and Groups
True or False: Can user bob run more /data/abc.txt?
drwxr-xr-x. 17 root root 4096 23:38 /
dr-xr-x---. 10 sue payroll 128 03:38 /data
-rwxr-xr--. 1 bob bob 100 21:08 /data/abc.txt
Answer : Not enough information
Explanation
-
To access the file, user bob needs:
xon/xon/dataron/data/abc.txt
-
Bob already has required permissions on
/and the file. -
Access to
/datadepends on group membership:- If bob is in
payrollgroup → permissions arer-x→ command works - If not → permissions are
---→ command fails
- If bob is in
Lesson Learned
Always consider user, group, and group membership when evaluating permissions.
6. Permission Priority
True or False: Can user bob run more /data/abc.txt?
drwxr-xr-x. 17 root root 4096 23:38 /
dr-xr-x---. 10 bob bob 128 03:38 /data
----rw-rwx. 1 bob bob 100 21:08 /data/abc.txt
Answer : False
Explanation
- The file owner is bob
- Owner permissions on
abc.txtare--- - Only owner permissions are checked for the owner
- Group and others permissions are ignored for bob
- Without
rpermission,morecannot read the file
Lesson Learned
File owner permissions override group and others permissions.