Search code examples
linuxpermissionsfile-permissionsdirectory-traversal

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?


Solution

  • 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.