If a user is in group2, then they'd follow the group permissions for the directory FOLDER. i.e.
rwx
Presuming that they are not user1 and also not in group1, then we'd look at the "other" permissions for FILE. i.e.
r--
Hence, they only have read permissions for this file. Note that this is a bit confusing. They cannot directly modify this file, since don't have write privileges. However, since they have wx
for the directory, they could rm
this file, then replace it with a new one. (N.B. the inode would probably change, and they wouldn't be able to chown
it to the original owner, so it's not exactly the same as directly modifying the file.)
So in general, the permissions inherit from the most-parent directory. As permissions get more restrictive, they restrict the children files and directories. However, as above, if you have wx
permissions to the top-level directory, there are workarounds.
EDIT
Similarly, if you edit the file with vim
, then you'll see a change in inode. It's not "editing" it, but "over-writing" it.
$ echo foo > file
$ ls -li file
5213942 -rw-r--r-- 1 sparhawk sparhawk 4 Aug 16 15:34 file
$ sudo chown root:root file
$ ls -li file
5213942 -rw-r--r-- 1 root root 4 Aug 16 15:34 file
$ vim file
$ ls -li file
5214750 -rw-r--r-- 1 lee lee 7 Aug 16 15:35 file
Note the change in inode after vim
overwrites the file. Also note that vim gave a warning that the file was readonly. I had to save with :w!
.