Carrying out actions on multiple files

Chances are you’ve downloaded an archive and extracted it into your web space, then noticed that all of the files are set to world writeable. Some people wouldn’t know any better, but it could be a security risk, and if your server has something like suPHP set up, it will throw up a 500 server error when you try to load a file.

You could just use wild-cards, which usually works fine on normal files, but what about separating files and directories?

Personally, I stumbled upon this tip somewhere on the ‘net and adapted it for my use:

[code]find . -type d -exec chmod 755 \{\} \;[/code]

That simple little line will recursively scan through the current directory and chmod all directories to 755. You could change the -type switch to f to find files instead of directories, or the command after the -exec switch to something else to do what you want, for example:

[code]find . -type f -exec chmod 644 \{\} \;[/code]