Setting default permissions for new files under a directory
I'm trying to find a way to set default permissions for newly created files in a specific directory.
I have a directory called scripts, in which I write scripts while I teach myself shell scripting and python. I need all these scripts to be executable. Right now I do it at file creation: Code:
touch newfile && chmod +x newfile && vi newfile Is there a way to set default permissions for new files under a specific directory? |
umask is the shell built-in that controls new file perms. Not sure of any other way to make it apply to one directory only.
However, if this is something you really wanted to do you could use this as a learning experience to create a watchdog script via Perl/Python or even bash to watch for newly created files and make them executable. (Might want to be careful the way you write it to make sure it doesn't over-utilize the server.) |
Or you could alternatively create a bash script that you can use to create files for you.
Such as: Code:
./createnewscript.sh newscriptfilename.sh |
Thanks for the answer, and for the suggestions that I script what I needed. It took a bit of digging, since I'm kind of new to this aspect of Linux, but I was able to write a simple bash script using inotify. I don't yet know enough to know how much of a load it puts on the server, but here's what I came up with:
Code:
while true ; do Thanks again! |
All times are GMT -5. The time now is 10:52 PM. |