5

On Mac using terminal and "chown" command I can set owner for a folder like this:

sudo chown -R _www somefolder

However this replaces me with _www. I.e. I'm not in the list of owners anymore.

enter image description here

I then have to open folder properties in Finder, add myself as a second owner and set permissions using the GUI.

enter image description here

And this is what the ACL looks like:

enter image description here

Is there a way to add TWO owners using terminal? In other words how to add a second owner to a folder using terminal? Not necessarily chown.

PS: Just in case.. on the screenshots users "_www" and "Oleg (Я)" have permissions "Read and write".

  • 1
    How do the permissions of the file with two owners look like in terminal. I doubt the Mac does this via POSIX file attributes, but via some ACL stuff. – Philippos Feb 9 '18 at 14:01
  • You can't add a second owner. You may check for ACLs, if ordinary group-based security permission is not enough. You may also consider to own the file by a third user (root, nobody, or any neutral third account), and giving the access to both of users by group-based rules or by acls. – user259412 Feb 9 '18 at 14:25
2

Found the answer (type this in Terminal):

sudo chmod +a 'Oleg allow list,add_file,search,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity' somefolder

Where 'Oleg' is a user name and 'somefolder' is a folder name in question.

The permissions inside single quotes after the 'allow' keyword are just copied from the output of ls -le

Now both users '_www' and 'Oleg' can read, write files and subdirectories, etc.

That was the intention.

Strictly speaking yes, you can not add a second "owner" in POSIX attributes sense, e.g. via Chown.

However in Mac you can give owner-like permissions to numerous users via ACL like Philippos commented (thanks for hinting).

1

This is not possible because a Unix file have one owner, try to use a group instead.

  • Side note: surprising, but in Unix, the Owner and the Group are both a single integer, and nothing forbids for multiple users to have the same user-id. Thus, in the view of the kernel permission checking, there is no essential difference between uid and gid. – user259412 Feb 9 '18 at 14:23
  • @peterh "two users" with the same uid are not "two users" but one user with two names. The uid is what defines a user, not the name. Also, "there is no essential difference between uid and gid" is just nonsense - were you drunk when you wrote that? – cas Feb 10 '18 at 1:59
1

this is a xy-problem

X:problem, how can two user access same file, with same right ?

solution I use multiple chown => Y:problem

Solution for X problem

according to http://aplawrence.com/MacOSX/acl.html

you can use

 chmod +a "allow Oleg list,search,add_file,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown"
 chmod +a "allow _www list,search,add_file,add_subdirectory,delete_child,readattr,writeattr,readextattr,writeextattr,readsecurity,writesecurity,chown"

I can't test it right now, I don't have mac OS 10.5 available.

You might replace the long string above with the result of ls -e

Y:solution: I try to use multiple chown.

This is not possible: Unix/Linux/OS X's file have only one owner at a time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.