I have a directory owned by root, after I copy files into it. All exe files can only be run as root. But I would like everyone to be able to run it. Surely, I can use chmod -R u=rwX,g=rX,o=rX every time after I add new files into it. However, this is very annoying. Is there any thing I can set in the directory to automatically allow all users to run the exe?


Using umask 0022 before making the copy, you will get all new files with -rw-r--r-- permissions by default, but files can be made executable only invoking directly chmod +x on them.

You can use the abbreviated command: chmod -R a+rX directory to do it manually.

To automatically set all file permissions you can use inotifywait like that:

inotifywait -qm <directory> -e create -e moved_to -e modify \
 | while read a b c; do chmod a+rX "${a}${c}"; done
  • alternative abbreviation: chmod a+rX. according to taste
    – sourcejedi
    Oct 21 '16 at 21:13
  • I've lost a piece of info in the topic, I've corrected the answer thanks to @sourcejedi
    – nrc
    Oct 21 '16 at 21:33

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.