Linux doesn't support permission inheritance, so you can't do what you asked in the question topic.
The best you can do is to set default POSIX ACL which will apply to all newly created files and directories. This is not the inheritance, just the default:
setfacl -m default:user:<username>:rwx <dir>
setfacl -m default:group:<groupname>:rwx <dir>
After this, if anybody creates a file or directory in (if they are allowed to create objects there, of course), that object will get additional ACL user:<username>:rwx
and group:<groupname>:rwx
. You can set default permissions for owner and group-owner by setting <username>
and <groupname>
blank.
This "default" could only be set upon a directory, because there is no point to apply this to files. Permissions set this way also get masked with umasks, so if some bit is dropped in umask, this bit will be dropped from a permission. For instance, when you create a file, if you don't give it executable bit, it wouldn't be made executable (as expected). Created subdirectories will also have the same "default" ACLs set, so its descendants will have these ACLs set too. You have to remove or change ACLs on subdirectories after creation to stop this propagation.
Check the ACL with getfacl <dir>
. Of course, there could be several such defaults (and it seems you have to end up with several rules); at least, requirements that I encountered always mandated the presence of at least two default group ACLs).
You can not set "default file owners" this way, the owner will always be set to creating process effective uid. By default, group-owner will be set to process gid, but you can change that by using the setgid bit on the parent directory:
chmod g+s <dir>
after that, any object created in that directory will copy its group-owner by default, even if creating user doesn't belong to that group. This setgit bit propagates to subdirectories.
Owners can set group-owner to any group that they belong to. If they don't belong to the group derived by setgid, they can change their file group-owner to any group they belong to, but after that they won't be able to change it back into setgid value.
I want to note again explicitely, this is not an inheritance, this is setting defaults which is not exactly the same. If you change something on parent object afterwards, already created objects will always retain their permissions in Linux.
While, for example, in Windows, when you set sub-object ACLs to "inherit", changing parent ACLs will affect descendants, which is the proper inheritance.