Thursday, November 3, 2011

How to set different permissions for subfiles and subdirectories

To give different permission settings for all subdirectories and subfiles use following commands:

find /start/location/ -type f -print0 | xargs -0 chmod 644
find /start/location/ -type d -print0 | xargs -0 chmod 755

If you receive such an error "permission denied", run above commands as root with "su" parameter or try them as following:

sudo find /start/location/ -type f -print0 | sudo xargs -0 chmod 644
sudo find /start/location/ -type d -print0 | sudo xargs -0 chmod 755

In here permission settings of all subfiles will be changed to "644" and all subdirectories will be changed to "755".