I have done

chmod -R 644 .

inside the directory dir

My user's permissions are drw-r--r-- and i'm the owner of the directory

When trying chmod 755 dir, error is popped

chmod: changing permissions of dir Operation not permitted

The same error is popped when doing ls even as root

How to change permission back to 755 and allow its deletion and modification?


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)

  • Coincidently I didn't know that you selectively ignore files by using capital X until i started reading up to give you an answer! – Stephen Mason Dec 8 '16 at 12:06
  • Haha, my bad! I'm still waking up – Stephen Mason Dec 8 '16 at 12:16

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.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.