Is there a way to recursively change the access rights of a specific folder to 755 and files to 644 Without using the find function and having sub-directories in that folder (don't want to change those) ?

Currently I'm using chmod 755 -r folderName/

using find I think its something like that :

find /specific_folder/ -type f -print | xargs chmod 644

You can do it this way:

chmod -R a=rX,u+w folderName

For CentOs the command is:

chmod -R a=rx,u+w folderName

But it will rewrite subdirectory permissions. As the consequence: you cannot do what you want with just chmod.

| improve this answer | |
  • will that only work on files ? what about sub-directories .. i dont want to change their permissions – Tarek Jun 29 '11 at 11:30
  • yes, it does work for sub-directories as well. – akond Jun 29 '11 at 11:32
  • just tried that and it doesn't work – Tarek Jun 29 '11 at 11:43
  • You mean doesn't work at all or what? – akond Jun 29 '11 at 11:45
  • yes it doesn't work at all – Tarek Jun 29 '11 at 11:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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