[chmod] Permissions

change permissions on all dirs

find . -type d -exec chmod 700 {} \;

change permissions on all files

find . -type f -exec chmod 600 {} \;

change permissions recursively

use the -R flag

chmod 755 -R var/

make executable

chmod +x file

copy permissions from another file

On GNU/Linux chown and chmod have a --reference option

chown --reference=otherfile thisfile
chmod --reference=otherfile thisfile

Example from Magento

Enter the following commands to set permissions:

find . -type f -exec chmod 400 {} \;
find . -type d -exec chmod 500 {} \; 
find var/ -type f -exec chmod 600 {} \; 
find media/ -type f -exec chmod 600 {} \;
find var/ -type d -exec chmod 700 {} \; 
find media/ -type d -exec chmod 700 {} \;