Sometimes you need to recursively set a specific UNIX permission for a whole set of files and/or directories. And you want to have a different permission for your files and for your directories.
For example, when installing a CMS like Joomla (or Moodle), you might want to recursively set the UNIX permissions to 700 for all the directories contained in your web root (say, your htdocs). And you want to do the same for all the files, but this time to 600.
This can easily be achieved by entering your htdocs and by using the find command:
find . -type d -exec chmod 700 {} +
find . -type f -exec chmod 600 {} +
The commands should be read as follows:
“Read everything in the current directory, recursively. For every single item that is of type directory (file) change permissions to 700 (600).”
The {} + option (refer to the find man page) runs the specified command on the selected files, but the command line is built by appending each selected file name at the end.
More information about UNIX permissions here.

Discussion
No comments yet.