How to chmod 755 all directories but no file (recursively)

To recursively give directories read&execute privileges:

find /path/to/base/dir -type d -exec chmod 755 {} +

To recursively give files read privileges:

find /path/to/base/dir -type f -exec chmod 644 {} +

If there are many objects to process:

chmod 755 $(find /path/to/base/dir -type d)
chmod 644 $(find /path/to/base/dir -type f)

To reduce chmod spawning:

find /path/to/base/dir -type d -print0 | xargs -0 chmod 755
find /path/to/base/dir -type f -print0 | xargs -0 chmod 644

Alternative

chmod -R u+rwX,go+rX,go-w /path

http://superuser.com/questions/91935/how-to-chmod-755-all-directories-but-no-file-recursively

https://gist.github.com/francisbyrne/3731497

Spread the love

Leave a Reply

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