Skip to content

Comment on Delete files owned by root, without being root

Comments

Maybe my brain has been twisted by too many years of using Unix, but that's exactly how it's supposed to work. "rm" is really editing the directory, not the file, so the owner of the directory is what matters. The file may not actually even be deleted; if there's a hard link to it from another directory the file will still be there in the other places. inodes are awesome.

I agree. This should not be surprising. The ability to link a file to a directory is different from the set of permissions necessary to change the data in the file.

Here's a practical example: I can create ~/public with permissions 777 (fully permissible) and allow my friends to read and write freely in it.

They can create files with permissions 600 (only they can read/write)

I can't open up these files and read the contents, but I can remove the entire thing from my home directory.

It's not twisted; it's just that you know it. This seems like a great article for someone who doesn't yet know it.

Also let's not forget about hard links, so that even if you 'rm' the file it will still reside ...

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.