Any way to force files to inherit owner permissions from parent directory?
Linux has something known as Access Control List (ACL). This is a way to extend standard unix permissions and fine tune them. One of the advantages is that it does have inheritance. What could be done, has been referenced by a related post on serverfault, and in your particular case:
sudo setfacl -Rdm g:somegroup:rwx /path/to/parent
As for forcing the files to be owned by the same user, it has been discussed in Getting new files to inherit group permissions on Linux, however forcing the same owner on each file is far more troublesome than having the file to be forced to have same group ownership as done via setfacl
. If the group has exactly the same permissions as the owner, there's no point to force the same ownership. Of course, you could always use inotifywait
and trigger chown
upon file creation, but that's pointless since group ownership already gives you control over the file.
See also:
Related videos on Youtube
S. Wyatt Young
Updated on September 18, 2022Comments
-
S. Wyatt Young over 1 year
Is there any way to force a file, created within a directory, to inherit ownership from the parent directory? I tried the sticky bit, but that doesn't seem to work.
Example of what I'm looking for:
drwxrwxr-x www-data somegroup parentdir
When parentdir/newfile.htm is created by someuser:
-rwxrwxr-x www-data somegroup newfile.htm
NOT
-rwxr-xr-x someuser somegroup newfile.htm
Any way this can be done? Thank you!
-
muru almost 9 yearsThe sticky bit or the setgid bit?
-
S. Wyatt Young almost 9 years@muru, I believe they're one in the same. What I'm calling the sticky bit is the flag that makes sure children inherit the group owner from the parent directory.
-
muru almost 9 yearsThat's the setgid bit. The sticky bit is what you see on
/tmp
- which prevents others from deleting your files. -
S. Wyatt Young almost 9 years@muru: Ah! Thank you for clarifying that bit for me.
-
Lucas Pottersky over 3 yearsi'm always surprised how technologies can do crazy things, but not simple things like that. (at least not in a straight-forward way)
-
-
S. Wyatt Young almost 9 yearsNot what I'm looking for. I'm looking to avoid changing permissions manually. Also, while HTML files don't need executability, scripts do. I might just be running scripts. :)
-
WinEunuuchs2Unix over 5 yearsOP has abandoned Ask Ubuntu and no answers with upvotes on this question. So +1 not just for a good answer but also to prevent the software from bumping this to the home page for infinity :)
-
Sergiy Kolodyazhnyy over 5 years@WinEunuuchs2Unix Yeah, it's an abandoned question, but it might be useful to some :) Thanks, btw
-
WinEunuuchs2Unix over 5 yearsI guess what I meant to say is OP won't accept answer nor upvote it. Happy New Year in CO in one hour 51 minutesBTW :)
-
Sergiy Kolodyazhnyy over 5 years@WinEunuuchs2Unix Happy New Year to you,too ! It's actually going to be in 1 hour and 51 minutes or so - it's 10:14 pm here. Eh, OP doesn't need to accept - if others find it useful, it's enough for me :)