I am trying to understand file/dir permissions in Linux. A user can list the files in a directory using
cd test ls -l
Even if the user issuing above commands does not have read, write or execute permission on any of the files inside the test directory, still he can list them because he/she has read permissions on the test directory.
Then why in the following scenario user B can change permissions of a file he owns but does not have write permissions of the parent directory?
User A, makes a test directory and gives other users ability to write in it:
mkdir test chmod o+w test
User B, creates a file in test folder.
cd test touch b.txt
User A removes write permission of others from the directory
chmod o-w test
User B, can successfully change permissions, even though permissions are part of directory and this user does not have write permission on the parent directory of the file he owns
chmod g-r b.txt
chmod not fail since the user cannot modify the directory which has the file information - permissions etc?