2

I've been experimenting with file permissions and ownership lately, and I tried this:

touch a
sudo chown root:root a
sudo chmod 000 a

I can't read, write, or execute the file, but I can still delete it using -f. Why is this? I don't own the file, and nobody has any permission for the file. Shouldn't you need root to delete a 000 file you don't own?

---------- 1 root  root      0 Apr  3 20:18 a
2

What you call "delete a file" is really just deleting a reference to the file in a directory , and the right to do so is the right to modify the directory; the file permissions play no part in this. If that was the last reference to the file, the file is destroyed, but that is a separate issue.

| improve this answer | |
  • What do file permissions change, then? Does this mean you couldn't srm it? – tkbx Apr 4 '13 at 0:42

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