5

Is it possible to create a directory that ordinary users cannot delete, but they could create and delete files and subdirectories inside this directory? i.e. for

/share/permanent/

users could create files and directories both in /share and /share/permanent but cannot delete /share/permanent directory (nor /share directory either).

/share should be a samba-share so permissions maybe be set on smb.conf if not possible on file system?

  • 1
    chown /share/permanent to a user no one can access (e.g. root) and write protect /share – M.Fooladgar Dec 15 '15 at 16:06
0

In your scenario where the directory is /share/permanent/

    mkdir -p /share/permanent
    chmod 755 /share
    chmod 777 /share/permanent
    sudo chown -R root:root /share

This works because now deleting /share/permanent would be considered writing to share, which is only writable by root. /share/permanent/ can be written to by and read by anyone.

If you want to make it so that people can only delete file that they own you can set the +t flag with chmod.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.