Fixing permissions with find "the quick way"

Probably I'm not the only one having to fix some permissions on an entire tree and being annoyed by the fact that, sometimes, you have to do it twice: one time to fix the file permissions and second time to fix folder permissions.

Let’s say you want to grant “read” to “all”. Running “chmod -R a+r” doesn’t help with the folders, which require an extra “+x” so you could enter them. But setting “chmod -R a+rx” make also the files executable, and you don’t want that.

So you may end up with idiotic things like this:

  chmod -R a+r /path
  find /path -type d -exec chmod 755 {} \;  

This is not only stupid, but also slow. Fortunately, there's also a quick way to do it:

  chmod -R a+rX /path

where X means "set execute only if the file is a directory or already has execute permission for some user". And most of the time, that's exactly what you need. Shorter to type and faster to run.