CodePark/ questions / Linux commands & permissions
START PRACTICINGPRACTICE
Backend question · OS, networking & Linux › Linux commands & permissions

User alice, who is not root and not in group root, runs cat /data/report.txt. What happens?

$ ls -ld /data /data/report.txt
drwx------ 2 root root 4096 Jan 10 09:00 /data
-rw-r--r-- 1 root root  512 Jan 10 09:00 /data/report.txt
Permission denied, because alice has no execute (search) permission on /data

To open a file by its path, you need execute (search) permission on every directory along that path. /data is 700, so only its owner can pass through it. Alice can't, so she gets "Permission denied" before the file's own permissions are even checked.

"It prints the file, because the file is world-readable" is wrong: the file's world-readable bit never comes into play. "Permission denied, because the file isn't executable" is also wrong: reading a file needs read permission, not execute.