Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Is there any Mac OS X tools or scripts which allow me to change sharing/permission properties of files and subfolders in a folder recursively? For example, to let everybody or a specific user able to read and write, read only, or write only.

share|improve this question

3 Answers 3

up vote 22 down vote accepted

Try the chmod command. For example, if you have a directory name mydir, the following command will enable read/write for that mydir recursively.

$ chmod -R +rw mydir

For more information:

$ man chmod
share|improve this answer
6  
Good answer, bad example. When adding read and/or write access to folders, you need to add execute ("x", aka search) access as well, or else the r/w are kinda useless. On the other hand, you don't generally want to add execute to files. When doing a recursive change, you're operating on a mix of files and folders. The answer is to use chmod's "smart execute" (capital X) feature: chmod -R +rwX mydir will add execute only when it makes sense. –  Gordon Davisson Oct 9 '09 at 0:07
    
Gordon: Great observation. However, a directory normally has the x turns on, unless the user does something funky to turn it off. –  Hai Vu Oct 9 '09 at 6:33
    
Depends on the initial permissions. If you take a look in a default-config Mac home folder, for example, you'll see for most of the folders (Desktop, Documents, Library, etc) the owner has full (rwx) access to everything, but group and others have no access (no read, write, or execute). If you're adding read or write for group or others to one of these folders, you need to add execute as well. –  Gordon Davisson Oct 9 '09 at 19:18

Select the root folder that you'd like to work with and open the Inspector (CMD-i or right click and "Show Info"). The bottom panel is where you can manage permissions.

Add and remove permissions to the list there. To apply the same permissions recursively to every subfolder, click the cog and select "Apply to Enclosed Items..."

Note: I noticed that the "Apply to Enclosed Items..." is greyed out when the little lock icon at bottom right hand side of window is locked. If this is the case just click on the lock to unlock it by entering your credentials and then try again with "Apply to Enclosed Items..."

share|improve this answer
    
While generally useful, it won't accomplish what's asked for. It replaces permissions in subdirectories, instead of e.g. adding a user to all of them, no matter what the permissions were before. –  Daniel Beck Jan 4 '11 at 16:29
    
@DanielBeck you're wrong, it applies all elements of permissions, chmod and chown this is the correct 'mac' way to do it –  Rob Dec 2 '11 at 10:43
    
i just tried this answer (on a test folder) and it did not work correctly: since a folder is typically 'executable', that bit was also set on all enclosed files, which is wrong. i just wanted to change user and group. –  flow Nov 12 '13 at 21:44

You want to use the chmod and chown commands.

If I remember correctly, you can change the permissions like this:

chmod -R +a "joshhunt allow read" /some/file/or/folder/
chmod -R +a "Guest deny read" /some/other/folder/
chmod -R +a "Guest deny write" /some/other/folder/

For more details one these commands, look up their respective man pages in Terminal:

man chmod
man chown
share|improve this answer

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.