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?

3 Answers 3


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)

  • 1
    Coincidently I didn't know that you selectively ignore files by using capital X until i started reading up to give you an answer! Dec 8, 2016 at 12:06
  • Haha, my bad! I'm still waking up Dec 8, 2016 at 12:16
  • This gives execute permissions to all below dir to all users. You may not want that. There is another answer here which gives it only to directories (find dir -type d -exec ...). IMHO that is a better solution. Oct 2, 2020 at 15:30
  • For me, the problem was just preceding the command with sudo. Trivial, but should be stated.
    – Gulzar
    Oct 6, 2020 at 6:29

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
  • Can you explain what's with the '\!'? The rest looks familiar. Oct 2, 2020 at 15:31
  • @SybillePeters the ! means not. It is a special character for some shells, and so needs to be single-quoted or escaped with a backslash so that the shell doesn't try to process it. Oct 2, 2020 at 15:42
  • Of course! It's obvious now. Thanks. Oct 2, 2020 at 18:44

enter image description hereHello, I think I have a solution to your problem. Here is the problem:

chmod 777

You did not put sudo so try putting sudo in like this:

sudo chmod 777
  • 1. Permissions 777 give full control to everyone. Do you really want other users to be able to edit or even delete your files? 2. If they're your files you don't need sudo Jan 28, 2022 at 9:01

You must log in to answer this question.

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