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?
Asked
Active
Viewed 1,497 times
1
Christopher
- 15,611
- 7
- 51
- 64
Wang
- 1,212
- 2
- 15
- 26
1 Answers
2
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
nrc
- 281
- 1
- 4
-
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