I have a directory with numerous files. Part of the files have the 755 permissions and the other part have 644 permissions. I'd like to convert the files with 755 permissions to 644. I have tried the following line by running it from the directory itself:

find . -perm 755 -exec chmod 644 {}\;

However as a result, the permission changed only for the directory itself and after changing it back I found out that the files permissions remained unchanged. Do I miss something?

  • Your command removes the executable bit from the directory, making it impossible to chdir to it and look at the files it contains. That's why the command doesn't seem to be working. Try find ./ -type f -exec chmod -x {} \; instead. – Shadur May 22 '12 at 11:20

Ok, it seems that I've found the problem. It seems that there must be a mandatory space between the {} and \;, so the command will look like this:

find . -perm 755 -exec chmod 644 {} \;

Rather than:

find . -perm 755 -exec chmod 644 {}\;

Also the issue with changing the directory permissions can be solved by adding a -type f flag, so it'll look as follows:

find . -type f -perm 755 -exec chmod 644 {} \;
| improve this answer | |
  • 6
    You could use + instead of \; to reduce the number of subprocesses created. – Kevin May 22 '12 at 14:48
  • -type d will find directories. -type f will find files. – Mick T Mar 13 '17 at 21:58

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.