Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Please someone assist me with chmod, I have the following file structure

-dir1
--file1
--file2
--dir1a
---file1a1
---file1a2
--dir1b
---file1b1
---file1b2

How do I chmod 655 to all files under dir1 and all subdir? So all files will have 655 permission and all dir will remain as they were.

Thank you

share|improve this question

2 Answers 2

up vote 20 down vote accepted

Better to use

find . -type f -exec chmod 655 {} +

The other proposed solution from @sagarchalise will not work if filenames contain spaces.

share|improve this answer
4  
Relatedly, to chmod all directories you can use find . -type d -exec chmod 755 {} + to change all directories to 755. –  Kris Harper Aug 24 '11 at 13:02
    
this works, no pain :). Thanks! –  netic Aug 27 '11 at 2:37

I think going inside dir1 and

find . -type f | xargs chmod 655

will do the trick.

share|improve this answer
    
this works too but i've got some warning with "No such file or directory" –  netic Aug 27 '11 at 2:39
    
@manetic: it depends, as said in my answer, on filenames containing spaces. –  enzotib Aug 27 '11 at 5:51

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.