Reputation: 1115
I have a folder with drwxrwxr-x permissions, where the owner is uploading his own files. I want to upload on that directory a readme file. The owner of the folder shouldn't have the right to delete that file. How I can do that? What rights should I set for the directory & for the file.
Upvotes: 0
Views: 936
Reputation: 10271
There are ways of doing this with ACLs, but the easiest way, if your OS supports it, is to make readme
an immutable file. A file with the immutable flag can't be modified, deleted, or renamed, even by the owner or the owner of the containing directory. On Linux, this would be done with sudo chattr +i /path/to/directory/readme
. On Linux, not even the owner of a file can remove the immutable flag (well, unless the owner can run a process with the CAP_LINUX_IMMUTABLE capability).
Upvotes: 1
Reputation: 612
The file should have drwxr--r--, this way only you, the owner of the file, have the ability to delete it.
chmod 744 <file>
Upvotes: 0