I experienced some weird stuff:
berni@zero:~$ touch wiki
berni@zero:~$ sudo chown root. wiki
berni@zero:~$ sudo chmod 000 wiki
berni@zero:~$ ls -l wiki
---------- 1 root root 0 2010-12-11 15:14 wiki
Summary: I created a file which nobody should be able to access in my HOME (~)
My user has default ubuntu permissions, no system tweaks etc.
But I'm able to delete the file without root permission!
berni@zero:~$ ls -l wiki
---------- 1 root root 0 2010-12-11 15:20 wiki
berni@zero:~$ rm wiki
rm: remove write-protected regular empty file `wiki'? y
berni@zero:~$ ls -l wiki
ls: cannot access wiki: No such file or directory
berni@zero:~$
This does not work in /tmp
or any other folder (!= HOME).
Does anyone knows why this is the case?
Deleting files does not require any permissions on the file or directory you are going to delete, it requires that you have writing permissions in the parent directory and either is the owner of the file or the parent directory.
For example:
You cannot delete the
/foo
directory here, even though you are the owner of it, because you do not have write permissions in the parent directory (/
). You can delete/foo/bar
, though, since you do have write permissions in the directoy/foo
.