Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

3 Answers

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.

share|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
add comment

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

eg.

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.

share|improve this answer
add comment

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
share|improve this answer
    
I noted in my post that the --reference option is not there. –  leanne Mar 6 '12 at 23:04
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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