Linux and Command-Line Basics
The directory d has permissions rwx--x--x (711), and the file f.txt in it has rw-r--r-- (644). A user who is neither the owner nor the superuser runs "ls d" and "cat d/f.txt". Which of the following is the result?
- Als d shows the listing, but cat d/f.txt is not permitted because the directory permissions are insufficient
- BNeither ls d nor cat d/f.txt is permitted
- Cls d is not permitted, but cat d/f.txt shows the contents
Show answer and explanation
Answer: C. ls d is not permitted, but cat d/f.txt shows the contents
For a directory, r is permission to read the list of names in it, and x is permission to enter it and reach a file by name. Others have only x, so ls d gives "Permission denied", but d/f.txt, whose name is known, can be reached. f.txt itself grants r to others, so cat can show its contents. Conversely, in a directory with r but no x, the names can be listed but the files in it cannot be opened.
- A. This is the result for a directory with r but without x. For 711, others have only x, so the listing cannot be read.
- B. With x on the directory, a file can be reached by name. Whether it can be opened is decided by the permissions of f.txt itself.
- C. Correct. In a directory with only x, files whose names are known can be opened even though the listing cannot be seen.