Shell Permissions – How to Change Permissions of Multiple Files Found with Find Command

findpermissionsshell

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?

Best Answer

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 {} \;
Related Question