Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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
up vote 12 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
sudo find /path/to/someDirectory -type f -print0 | xargs -0 sudo chmod 644

and

sudo find /path/to/someDirectory -type d -print0 | xargs -0 sudo chmod 755
share|improve this answer
    
How is this better than the accepted answer? – kasperd Nov 27 '15 at 9:00

Your Answer

 
discard

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.