Reputation: 81
I would like to have a directory in my Linux machine with 777 permissions, however anyfile placed (copied/moved) inside will need to automatically have 666 permission set. In other words, is it possible in Linux to have a directory where any files placed side automatically becomes un-executable?
Upvotes: 0
Views: 534
Reputation: 85
A good way of doing this would be to use the "umask" builtin, this affects the file creation mask for the current shell environment, you can get the current mask with
umask -S
So to create files with a certain mask, you could do the following :
mask_for_file_creation="u=rw,g=rw,o=rw"
curr_mask=$(umask -S)
umask $mask_for_file_creation
#create files here
umask $curr_mask
providing the mask as the first argument to umask sets the mask to that value.
Upvotes: 0
Reputation: 295353
You can mount a filesystem with the noexec
flag; any file within such a system will not be executable even if its permissions indicate otherwise.
Upvotes: 1