I want to make all folders in a directory chmod to 755 and individual files to chmod 644. Is there a way I can use umask (e.g. umask 022) to specify these permissions in the future?

Thanks in advance.

find ~ -type d -exec chmod 755 {} \;
find ~ -type f -exec chmod 644 {} \;

echo umask 0022 > ~/.bashrc # [ this should be in your /etc/profile* already ]

You can solve this then using access control lists. man setaclf

Aside from this and or making a cron script that occasionally goes through and makes sure that everything is chmodded correctly in this directory there is no elegant way to go about this in linux.

  • Caveat with acl's, all files created in that directory would have the proper umask applied but any files copied over would have to be chmodded or as stated before you can have a recursive cron script that chmod's the entire directory
  • 2
    That change will affect all files and directories created by that user. I took the question to mean 'only in a particular directory'. – EightBitTony Jun 23 '11 at 5:45
  • Thanks, Your right EightBitTony, I fixed the answer to more appropriately address the question. – Wilshire Jun 23 '11 at 11:58

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.