A good alternative is this:
find . -type f | xargs chmod -v 644
and for directories:
find . -type d | xargs chmod -v 755
and to be more explicit:
find . -type f | xargs -I{} chmod -v 644 {}
I need this so often that I created a function in my ~/.bashrc
file:
chmodf() {
find $2 -type f -exec chmod $1 {} \;
}
chmodd() {
find $2 -type d -exec chmod $1 {} \;
}
Now I can use these shortcuts:
chmodd 0775 .
chmodf 0664 .
Piping to xargs is a dirty way of doing that which can be done inside of find.
find . -type d -exec chmod 0755 {} \;
find . -type f -exec chmod 0644 {} \;
You can be even more controlling with other options, such as:
find . -type d -user harry -exec chown daisy {} \;
You can do some very cool things with find and you can do some very dangerous things too. Have a look at "man find", it's long but is worth a quick read. And, as always remember:
Source: Stackoverflow.com