79

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.

5 Answers 5

103

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
4
  • 22
    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. Oct 9, 2009 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, 2009 at 6:33
  • 1
    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. Oct 9, 2009 at 19:18
  • 1
    Does not work for me, only apply to the main folder, not the sub-folders. Jun 17, 2016 at 16:12
38

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..."

4
  • 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, 2011 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, 2011 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, 2013 at 21:44
  • Fortunately, there will be a super hero everywhere in stackexchange ;-P Aug 4, 2020 at 11:51
12

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
1
  • 1
    Best way for when trying to specify permits for a particular user
    – megalucio
    Oct 9, 2017 at 1:36
5

You can use OSX interface:

  1. Select your directory
  2. Right click -> Get info -> Sharing & Permissions
  3. Add your user
  4. Set what you want privilege(Read&Write for example)
  5. Сlick on the three dots near plus icon(add user)
  6. Chose "Apply to enclosed items..."
  7. Confirmenter image description here
4

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.

sudo chmod -R 777

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .