I am trying to understand the corner case behaviors of rm command. In a folder owned and grouped by root, I have a file owned by user alice. However, user alice does not have any permissions on the file and containing folder is owner and grouped by root. (here I use the term grouped, meaning that it belongs to that group)
There are three scenarios when trying to remove the file based on other's permission bits of the folder.
Scenario 1: others have read and write permission. In this case, rm command removes the file with a prompt:
alice@cherry:.../folder_root$ sudo ls -alFh
total 0
drwx----wx 1 root root 4.0K Dec 10 15:14 ./
drwxr-xr-x 1 alice alice 4.0K Dec 10 14:39 ../
---------- 1 alice alice 0 Dec 10 15:14 foo
alice@cherry:.../folder_root$ rm foo
rm: remove write-protected regular empty file 'foo'? yes
alice@cherry:.../folder_root$ sudo ls -alFh
total 0
drwx----wx 1 root root 4.0K Dec 10 15:21 ./
drwxr-xr-x 1 alice alice 4.0K Dec 10 14:39 ../
alice@cherry:.../folder_root$
In the case that the other's permission bits is only execute, then we have the following behavior:
alice@cherry:.../folder_root$ rm foo
rm: remove write-protected regular empty file 'foo'? yes
rm: cannot remove 'foo': Permission denied
alice@cherry:.../folder_root$ sudo ls -alFh
total 0
drwx-----x 1 root root 4.0K Dec 10 15:14 ./
drwxr-xr-x 1 alice alice 4.0K Dec 10 14:39 ../
---------- 1 alice alice 0 Dec 10 15:14 foo
Now in the case that other's permission bits of the folder is only read, then here is the behavior:
alice@cherry:.../folder_root$ rm foo
rm: cannot remove 'foo': Permission denied
alice@cherry:.../folder_root$ sudo ls -la
total 0
drwx----w- 1 root root 4096 Dec 10 15:14 .
drwxr-xr-x 1 alice alice 4096 Dec 10 14:39 ..
---------- 1 alice alice 0 Dec 10 15:14 foo
I guess I don't understand why the read and execute permission bits are required to remove the file. Why is this the behavior?