1

I have a directory "project" that contains a set of subdirectories and files. I want to give 777 permission to the directories and files from my 666 in the same directory with chmod command in my directory "projct". how I can do that ?

  • Do you want to change only the files that have 666 or ALL files? – user205301 Mar 29 '14 at 14:59
  • 4
    Please clarify, what do you mean "files from my 666"? Do you want to give 777 to a directory and 666 to the files inside it? – terdon Mar 29 '14 at 14:59
  • 1
    I edited my question. i wan't to give permissions inside a directory – Amirov Mar 29 '14 at 15:14
3

To recursively give directories read,write&execute privileges to all.

sudo find /path/to/the/directory -type d -exec chmod 777 {} \;

To recursively give files read,write&execute privileges to all.

sudo find /path/to/the/directory -type f -exec chmod 777 {} \;
| improve this answer | |
  • 2
    chmod also has -R flag for recursive operation. – user205301 Mar 29 '14 at 15:00
  • 1
    Giving 777 permission to files is dangerous. – Avinash Raj Mar 29 '14 at 15:02
  • sudo chmod -R 777 /path/to/directroy – Avinash Raj Mar 29 '14 at 15:04
  • @AvinashRaj, I think you mean read&write only for files (666). The answer mentions 777 in second command! – user.dz Mar 29 '14 at 23:23
  • My answer gives read,write,execute permission to all inside a directory recursively. – Avinash Raj Mar 30 '14 at 0:09
3

To do everything in one run:

find ./ \( -type d -execdir chmod 755 '{}' \; \) , \( -type f -execdir chmod 644 '{}' \; \)

This traverses the tree below the current directory just once and sets 644 on files and 755 on directories.

| improve this answer | |

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.