change permission for files and directories in linux

This tutorial shows how to find all directories and files under the current directory and change the permission to 755 and 644 for all the existing files under it.

For Directories

find ./ -type d -exec chmod 755 {} \;

For files

find ./ -type f -exec chmod 644 {} \;

Another way

find . -type d -print0 | xargs -0 chmod 755;find . -type f -print0 | xargs -0 chmod 644

 

Use it only if you know what you are doing. Misusing this commands may result in server crash.

 

Leave a Reply

Your email address will not be published. Required fields are marked *