chmod: changing permissions of directory Operation not permitted

from the level above dir:

chmod -R a+x *dir*

to give all users (a) execute permission to all subdirectories and files (+x) or:

chmod -R a+X *dir*

to give all users execute permission to all subdirectories only (+X)


Since you've broken a tree of directory permissions with chmod -R you need to fix them all up. Run this from the directory above dir:

find dir -type d -exec chmod u=rwx,go=rx {} +
find dir \! -type d -exec chmod u=rw,go=r {} +

In case you're wondering, you need the x permission to access a directory. You need rx to be able to read it.

For those with a modern (GNU) version of chmod you may be able to do this all in one step. Symbolically this equates to "everyone (group/other) has the same as the owner, but remove write permissions from group/other"

chmod -R a=u,go-w dir