How to set permissions with chmod

Permissions are specified in octal using a three digit code. The first digit determines the owner permission, the second digit the group permission and the third digit everyone else's permission. In any of these, set 4 for read only, 6 for read and write or 7 for read, write and execute.

Here's a trick to set execute permission on directories only:

chmod -R 604 *
chmod -R u+X *
chmod -R o+X *