It's straightforward to realise that the permissions of a file are not relevant to the ability to delete that file. The ability to modify the directory listing is controlled by the directory's permissions.
However, for years I have believed that the purpose of the write permission was to allow modification of the directory, and the execute permission is for 'search' - listing files, or changing into the directory.
Today I discovered that one cannot rm
a file in a directory unless both the write and execute bits are set. In fact, without execute set, write appears almost useless.
$ tree foo/
foo/
└── file_to_delete
0 directories, 1 file
$ chmod -x foo
$ ls -ld foo
drw-rw-r-- 2 ire_and_curses users 4096 Sep 18 22:08 foo/
$ rm foo/file_to_delete
rm: cannot remove ‘foo/file_to_delete’: Permission denied
$ chmod +x foo/
$ rm foo/file_to_delete
$ tree foo/
foo/
0 directories, 0 files
$
I find this behaviour pretty surprising. For directories, what is the reason that execute is required to make write useful in practice?