I want to create a ZIP archive of a particular folder, it mainly contains photos copied from various sources gathered over multiple years. Unfortunately, the permissions are messed up. With ls I am seeing stuff like




The last one shows in the Finder as having duplicate user and group entries. When I try to zip the folder, an error occurs with files that have these permissions.

I am looking for a terminal command that resets all files inside a folder to


or for directories to



3 Answers 3


I'm not completely clear on what all is messed up, but you should be able to normalize the permissions with three commands:

sudo chown -R hhrutz:staff /path/to/folder

This sets the owner to hhrutz and the group to staff for the entire contents of the folder. Note that this requires admin rights, and you'll have to enter your admin password to confirm.

chmod -R u=rwX,go=rX /path/to/folder

This sets the file permissions to "-rw-r--r--" and directories to "drwxr-xr-x" (the "X" option means add execute permissions if appropriate).

Ok, now the posix permissions are all cleaned up, but OS X has two types of file permissions: posix (the "-rw-r--r--@ 1 hhrutz 757317411" part) and access control lists (the "0: user:hhrutz allow ...") part, and the ACL part is still a mess. To clean that up, use:

chmod -R -N /path/to/folder

This'll just remove all of the ACLs from the files and folders.

  • Ha, that did it! Also thanks for the chmod type X, hadn't seen that before.
    – user281318
    Jan 9, 2014 at 20:43

Assuming you still have rights to change file permissions at all, you can use the -R flag with chmod to recursively change file permissions. For example, to change all permissions in the folder \Users\Test\Desktop\PATH to be read, write, and execute for everyone, we can use:

chmod -R 777 /Users/Test/Desktop/PATH

The "777" means read, write, and execute for all users. To change the permissions to something else, read the information about the octal/numeric file system permissions notation (if you are unfamiliar with it) at https://en.wikipedia.org/wiki/File_system_permissions#Numeric_notation.

  • Ok, but this gives me duplicate user and group entries. I want to rid of the obsolete user as well. I am also confused, some files have an additional group _unknown, others haven't.
    – user281318
    Jan 9, 2014 at 0:29
  • So who are these files owned by exactly? If they're owned by your current user account, you can just run the command, and then delete the user account with userdel userName and the obsolete user will be gone. Otherwise you'll need to use chown to give yourself privileges before you chmod.
    – Caleb Xu
    Jan 9, 2014 at 0:32
  • But the userName is the same twice. I guess they have just different IDs, and one is obsolete. How can I make ls list all users? I tried -la@, but that doesn't show anything else.
    – user281318
    Jan 9, 2014 at 0:35
  • The list of ALL users is in the file /etc/passwd. Each line is a user, along with an indicator of if the user has a password set, user ID, group ID, user ID info (comments/human readable text), home dir, and default shell (see cyberciti.biz/faq/understanding-etcpasswd-file-format for more help on understanding this). You are looking for the user (specifically, its UID) that is obsolete and you are trying to delete.
    – Caleb Xu
    Jan 9, 2014 at 0:41

A rather stupid solution is to do a cp -r to duplicate the folder, this clears all wrong users. Then afterwards, you need to find the files which have no permission and call chmod a+r on them.

Edit: Ok, so the following shows all users:

$ ls -le interplay_l8.jpg 
-rw-r--r--@ 1 hhrutz  757317411  283266  7 Feb  2011 interplay_l8.jpg
 0: user:hhrutz allow read,write,append,readattr,writeattr,readextattr,writeextattr,readsecurity
 1: group:everyone allow read,readattr,readextattr,readsecurity
 2: user:hhrutz allow read,write,append,readattr,writeattr,readextattr,writeextattr,readsecurity
 3: group:everyone allow read,readattr,readextattr,readsecurity

This was after I did chmod u+rw. Using the n flag shows users numerically:

$ ls -len interplay_l8.jpg 
-rw-r--r--@ 1 1622704362  757317411  283266  7 Feb  2011 interplay_l8.jpg
 0: 60B880EA-8F35-47F9-B64B-5384CBA15697 allow read,write,append,readattr,writeattr,readextattr,writeextattr,readsecurity
 1: ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C allow read,readattr,readextattr,readsecurity
 2: 60B880EA-8F35-47F9-B64B-5384CBA15697 allow read,write,append,readattr,writeattr,readextattr,writeextattr,readsecurity
 3: ABCDEFAB-CDEF-ABCD-EFAB-CDEF0000000C allow read,readattr,readextattr,readsecurity

So there are multiple entries for exactly the same user...

Your Answer

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