From the post Why can rm remove read-only files? I understand that
rm just needs write permission on directory to remove the file. But I find it hard to digest the behaviour where we can easily delete a file who owner and group different.
I tried the following
mtk : my username
abc : created a new user
$ ls -l file -rw-rw-r-- 1 mtk mtk 0 Aug 31 15:40 file $ sudo chown abc file $ sudo chgrp abc file $ ls -l file -rw-rw-r-- 1 abc abc 0 Aug 31 15:40 file $ rm file $ ls -l file <deleted>
I was thinking this shouldn't have been allowed. A user should be able to delete only files under his ownership? Can someone shed light on why this is permitted? and what is the way to avoid this? I can think only restricting the write permission of the parent directory to dis-allow surprised deletes of file.