Linux – How to change permissions on folders, but not files

chmodlinuxmac-osxpermissionsrecursive

Is there a concise linux command (that will work on OSX) to change permissions on folders and all of their contents, but leave files in the current directory untouched? For example:

/parent/folder1 <-change permissions
/parent/folder2 <-change permissions
/parent/folder3 <-change permissions
/parent/folder3/file1 <-change permissions
/parent/folder3/file2 <-change permissions
/parent/file1 <-do not change permissions
/parent/file2 <-do not change permissions

Best Answer

You would need to run 2 commands I believe. This is one way to do it:

# find . -mindepth 1 -type d | xargs chmod 700
# find . -mindepth 2 | xargs chmod 700

The first does directories at the current directory level and deeper. The second does all files and directories deeper than the current directory.