How can I make a directory permission so that the user can write but cannot delete a file inside the directory?
"Amiel Ong" <amiel.ong@votek.com.ph> writes:> How can I make a directory permission so that > the user can write but cannot delete a file inside the directory?If your user shall *write* and *not* *create*, you can remove all his write permissions to that directory. This implies the file already exists. If he must be able to create a file this is more complicated, you will have to keep his write permissions at directory level, use the sticky bit and find a way to quickly change the file ownership once it is created. see chmod (2)
> How can I make a directory permission so that > the user can write but cannot delete a file inside the directory?Another way is to set the setuid bit. (chmod 4000) See chmod (1)> 4000 (the setuid bit). Executable files with this bit set will > run with effective uid set to the uid of the file owner. > Directories with this bit set will force all files and sub- > directories created in them to be owned by the directory > owner and not by the uid of the creating process, if the > underlying file system supports this featuremfg Sebastian Steenbuck
On Saturday 24 July 2004 17:00, Amiel Ong wrote:> How can I make a directory permission so that > the user can write but cannot delete a file inside the directory? >I suspect you mean "create" rather than "write". Some of the responses to your query seem to be unnecessarily complicated. I think you are looking for the same permissions as normally apply to the /tmp directory which can be achieved with: $ chmod ugo+xrwt my-special-directory If you want any user to be able to "write" to an "existing" file in the directory then in general I believe the permissions on that particular file must permit write for that user: $ chmod o+rw particular-file Ability to write an existing file does relate the ability to delete it. The latter depends on the permissions of the directory containing the file, as indeed does the ability to create a file. Malcolm