Matt Joiner Matt Joiner - 6 months ago 8
Linux Question

Get reason for permission denied due to traversed directory not executable

I have a file

/a/b
that is readable by a user
A
. But
/a
does not provide executable permission by
A
, and thus the path
/a/b
cannot traverse through
/a
. For an arbitrarily long path, how would I determine the cause for not being able to access a given path due to an intermediate path not being accessible by the user?

Answer

Alternative answer to parsing the tree manually and pinpointing the error to a single row would be using namei tool.

namei -mo a/b/c/d
f: a/b/c/d
 drwxrw-rw- rasjani rasjani a
 drw-rwxr-x rasjani rasjani b
                        c - No such file or directory

This shows the whole tree structure and permissions up until the entry where the permission is denied.