MacOS – How to check the effective file permissions/accessibilty for/of a given file and a given user

aclfilemacospermission

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?

Best Answer

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