chmod change files or directories recursively to the same value

Recursively change all files in your current working directory including files in subdirectories to 644:

find . -type f -print0 | xargs -0 chmod 644

Recursively change all directories in your current working directory including subdirectories to 755:

find . -type d -print0 | xargs -0 chmod 755

3 thoughts on “chmod change files or directories recursively to the same value

  1. Ewoud Kohl van Wijngaarden

    chmod -R doesn’t make a distinction between files and directories.

    The following is equal to the above commands:

    find -type f -exec chmod 644 {} +
    find -type d -exec chmod 755 {} +

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.