Is it possible to recursively copy the permissions of owner to group and others for all files in a given directory?

PS: my chmod is 5.97

  • chmod -R $mode $path/ ? – jirib Oct 25 '13 at 10:30
  • the problem is not recursivety, is how to set $mode in a way that it would copy the owner permissions to group and others? – RSFalcon7 Oct 25 '13 at 10:34
  • Do you know owner permission? if owner is 'rw' then it would be: chmod -R g=rwX $path/ – jirib Oct 25 '13 at 10:35
  • 1
    this would imply manually check every file and then set the permissions – RSFalcon7 Oct 25 '13 at 10:38

Yes, you can do this by using symbolic notation in chmod:

chmod -R go=u /path/to/directory

Typically the mode specifiers following the operator consists of a combination of the letters rwxXst, each of which signifies the corresponding mode bit. However, the mode specifier may also consist of one of the letters ugo, in which case case the mode corresponds to the permissions currently granted to the owner (u), member's of the file's group (g) or permissions of users in neither of the preceding categories (o).

  • 1
    Wow. Didn't know about it, nice! – jirib Oct 25 '13 at 10:37

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.