How do I check the effective file permissions (including ACLs)/accessibility for/of a given file and a given user (including service/system accounts) without checking the whole path manually?

Example: Suppose a user joe, and the file /long/path/to/file.txt. Even if file.txt was chmoded to 777, joe still has to be able to access /long/, and then /long/path/ and then /long/path/to/ before. If joe doesn't have at least read access to all folders in the path, he can't access (read/write/execute) the file. So the effective permissions for him (as "world/all" user) are 0 and he can't access the file.

Alternatively: how do I get a list of the permissions (including ACLs) of all users (including service/system accounts) for a given file?

An app or a bash script are also welcome.

A similar question with a slightly different focus has already been asked at Unix & Linux: How to check if a user can access a given file?

  • ls -del FILE|DIR will list both unix standard permissions and ACLs. What exactly are you looking for? – nohillside Sep 27 '15 at 12:51
  • @patrix Your ls command shows the file permissions for given file. But as described in the linked Unix&Linux question, permissions in the superior path may be set different so that a file which is world readable can't be read by an arbitrary user. Result: the file permissions are (77)7 but the effective file permissions are (77)0 (for an arbitrary user other than the owner & not in the same group) – klanomath Sep 27 '15 at 13:08
  • Can you please clarify your question then so it stands on its own and maybe add some examples? It also might be helpful to differentiate between file permissions (which are displayed by ls -del) and ability to access (which seems to be what you are looking for). – nohillside Sep 27 '15 at 13:13
  • Interesting challenge actually! If you take hard links on files into consideration, it will get very interesting :-) – nohillside Sep 27 '15 at 13:13

One commercial app which provides the effective permissions for a user and a selected file or folder is TinkerTool System:

In the example below the effective permissions of the file /private/var/log/clamav.log for the user Spotlight are shown. The user Spotlight can neither read nor write data.

enter image description here

Triggering the tab Show or Set Permissions the POSIX permissions/ownership are shown explicitly.

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .