Fixing permissions after copying from Samba

When copying from a Samba share, you can get all the files with the executable flag turned on. If all of those files are in fact plain, not executable files, you can just change all of them into non-executable ones. You would probably like to chmod -R 644 * but this would affect directories as well, leaving them untraversable. This is where find and xargs can help you. Let's find all the standard files with x flag on and execute chmod against them. As the files may contain spaces, it's better to separate the names with . The whole invocation follows.

find . -type f -perm +o+x -print0 | xargs -0 chmod 644

Author: automatthias

You won't believe what a skeptic I am.