Search Your Domain Name Here

Linux command to change permission recursively

While working in LAMP environment, several times we want to set permission of all files to 644 and all folders to 755. This can be done easily with chmod command. But problem arises when we need to do it recursively in all sub-folders and files contained within those sub-folders. Using chmod command can become very time consuming process. So we can make use of find command in this case. For example if we want to set the permission of all files to 644 in one go then we can execute the following command from the current folder:

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

Similarly if we want to set the permission of all sub-folders to 755 in one go then we can execute the following command from the current folder:

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

I hope that these two commands will become very much helpful to LAMP developers.

Leave a Reply

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

Facebook Auto Publish Powered By : XYZScripts.com