I need to make the permissions of a file exactly match the permissions of another file in OS X 10.6.

I don't see 'getfacl' or 'setfacl' as suggested in some other posts for Linux. And, it doesn't look like chown/chmod have a --reference option in Snow Leopard.

What is the equivalent on the Mac?

  • 1
    Do you want full ACLs or just regular UNIX file permissions? – Useless Mar 4 '12 at 19:51
  • Full ACLs. I need the files to match exactly. – leanne Mar 6 '12 at 23:03

OK, so for a straight ACL copy, I can't see a single command. However, you can put this in a script or function:

ls -le source | sed -En '/^ [[:digit:]]+: / { s/^ [[:digit:]]+: //; p; }' | chmod -E dest


function copyacl()
  ls -le "$1" \
    | sed -En '/^ [[:digit:]]+: / { s/^ [[:digit:]]+: //; p; }' \
    | chmod -E "$2"

$ copyacl sourcefile destfile

I feel like that sed script could be improved, but it seems to do the job.

| improve this answer | |

Use ls -le to see any acls a file has associated with it.

Use chmod to change or remove the acls. There are plenty of examples toward the end of the chmod man page to guide you.

Mac OS has a separate set of file access flags, apparently inherited from the BSDs. You can see those with ls -lO (that's dash ell oh) and modify them with chflags.

| improve this answer | |
  • Thanks for the thought, Kyle. However, I was hoping NOT to have to do all that. I'm looking for just a simple permissions copy like the ones noted in my question. – leanne Feb 8 '12 at 21:21

This one works:

chmod `stat -f %A srcFile` dstFile
| improve this answer | |
  • Nope, didn't work. – leanne Sep 29 '15 at 20:13
  • Hmm works for me. Which version do you have? – Primoz Rome Sep 30 '15 at 10:35
  • While -f %A work for me, it seems to be undocumented; -f %Lp does the same i.e chmod `stat -f %Lp srcFile` dstFile – Darren Bishop Jan 19 '16 at 8:09

Not sure if you are ask about standard UNIX permissions or for ACL's. Many versions of chmod have a --reference option to take the permissions of another file:

chmod --reference=~/backup/file ~/newfile

But you'll need to check the options for chmod on your Mac:

chmod --help
| improve this answer | |
  • I noted in my post that the --reference option is not there. – leanne Mar 6 '12 at 23:04

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.