Linux Permissions – Prevent Creating Directories but Allow Creating Files

directorylinuxpermissionssambaselinux

I have a directory shared through Samba. I want users to be able to create/modify/delete files but not create/erase directories. I haven't found a way to do it. Maybe with SELinux? But how?

Best Answer

The elegant way would be using richacls. But that is not an official part of the kernel yet and thus may be difficult to use for you.

An easy workaround would be to use the samba parameters directory mask and force directory security mode to render newly created directories useless (inaccessible) to the users so that they learn not to create directories.

The funny (and portable!) way would be to create so many (invisible) subdirectories that the file system's subdirectory limit is reached. If a new subdirectory is needed the admin would simply rename one of them.

Related Question