I want to set a folder such that anything created within it (directories, files) inherit default permissions and group , by anyuser (root also)
so , the content of this folder will be deleted by my user
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.
Sign up to join this communityI want to set a folder such that anything created within it (directories, files) inherit default permissions and group , by anyuser (root also)
so , the content of this folder will be deleted by my user
So, you'll need to be using a filesystem that supports User and Group ACL's (ext4 and xfs both do; but ext4 needs to be mounted with "acl" option set - "mount -o defaults,acl", for example)
Then you just need to set the default facl to include full permissions for your user and r/x for everyone else. Say the directory the files need to be in is called /directory and your user is called MYUSER, and you put "all other users" in a group called USERS, you'd do something like this:
setfacl -d -m u:MYUSER:rwx /directory
setfacl -d -m g:USERS:r-x /directory
setfacl -m g:USERS:r-x /directory
setfacl -m u:MYUSER:rwx /directory
Now any new files created in /directory are readable, writable, and executable by you; but only readable and executable by the USERS group.
To learn more about the use of filesystem ACLs, you can consult RedHat's excellent documentation
folder where anyboody can write here , (subfolder and file)
You can set the main folder's permissions: chmod 0777 but other users cannot access it unless the same permissions exist all the way to the root directory - not a good security measure in home directories. In addition SELinux permissions may cause problems with users writing outside their home directories.
i can delete the content with my user ; without use sudo
Deleting files created in such a directory would still have to be done as sudo/root unless the files are all created with a specific group with group write permissions and your user is also a member.
In short, what you're asking to do is not really feasible.