Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

How to change all file permissions to 644 and all folder permissions to 755 recursively using chmod in the following two situation:

  • If they had 777 permissions
  • Regardless of the permission (with ANY permissions)
share|improve this question

2 Answers 2

up vote 9 down vote accepted

find . -type d -perm 777 -exec chmod 755 {} \; (for changing the directory permission)

find . -type f -perm 777 -exec chmod 644 {} \; (for changing the file permission)

If they did not have 777 permissions, we easily remove the -perm 777 part.

share|improve this answer

Regardless of the permissions:

chmod -R a=r,a+X,u+w /your/path
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.