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?

  1. Als d shows the listing, but cat d/f.txt is not permitted because the directory permissions are insufficient
  2. BNeither ls d nor cat d/f.txt is permitted
  3. 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.
Practice this topic Back to topic

Books on Linux and Command-Line Basics Ad

As an Amazon Associate I earn from qualifying purchases.

More Linux and Command-Line Basics questions

  1. Which of the following correctly describes the sudo command on Linux?
  2. On many Linux systems, "ls -l /usr/bin/passwd" shows "-rwsr-xr-x 1 root root ...". Which of the following is the meaning of the "s" in the owner's execute position?
  3. When the commands above are run in order, which of the following is the content shown by the last cat?
  4. As shown above, in a directory where a.txt exists and nofile does not, the last command is run. Which of the following is the result?
  5. In the session above, which of the following is the value printed by the last command?