2

I have read permission a a file.

Which permissions and why are required _in the / and in the /path directories to be able to cat /path/file.txt ?

realtebo
  • 917
  • I posted an answer, because I need a 'why' , not only the information. Please review my question if not exact or incomplete – realtebo Jun 29 '22 at 10:33

2 Answers2

2

In order to access to any file located under the /path directory, the user must have the x (execute) permission granted for each of the directories in the path (this including root).

The reason for this is that cat will use the open system call. System call which : can fail with the following errors:

EACCES (…) or search permission is denied for one of the directories in the path prefix of pathname, (…)

Note that this page invites you to learn more about path resolution in Linux.

MC68020
  • 7,981
1

I can summarize what I learned from suggested question

For what I understand

  • 'r' is 'read the list of file names in the directory'
  • 'x' is 'do something which the content of the directory'

To read a file content i do not need the 'r' permission on directory because I know the filename so I do not need to read the directory listing

To read a file content i stille need the 'x' permission on directory because it's required to resolve the path to the file contents

What causes confusion in me the difference from file names and file contents. The first is in the directory the second is in the files. But to access a file i need 'x' because i need to access the directory itself anyway.

realtebo
  • 917