Notes

[chmod] Permissions

Edit on GitHub


Commands

change permissions on all dirs

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

change permissions on all files

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

change permissions recursively

use the -R flag

1chmod 755 -R var/

make executable

1chmod +x file

copy permissions from another file

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

1chown --reference=otherfile thisfile
2chmod --reference=otherfile thisfile

Example from Magento

Enter the following commands to set sensible permission defaults:

1find . -type f -exec chmod 400 {} \;
2find . -type d -exec chmod 500 {} \; 
3find var/ -type f -exec chmod 600 {} \; 
4find media/ -type f -exec chmod 600 {} \;
5find var/ -type d -exec chmod 700 {} \; 
6find media/ -type d -exec chmod 700 {} \;