I am running a small embedded system built using buildroot. I have come across this strange behaviour when trying to set up my file permissions on the target device. To illustrate what confuses me I tried the following simpler example
# cd /mydir
# touch tmp.txt
# echo "rubbish" > tmp.txt
# cat tmp.txt
rubbish
# chmod 0444 .
# chmod 0444 tmp.txt
# echo "new-rubbish" > tmp.txt
# cat tmp.txt
new-rubbish
I am really confused by this. How can I have set the file and directory to be read only and yet I am still able to modify the contents of this file? I have an executable within the same directory and when I try and execute it I get this
# chmod 0444 my_binary
# ./my_binary
-sh: ./my_binary: Permission denied
which behaves as I would expect it to. Clearly I have some fundamental misunderstanding of how the file access model works on Linux. Can anyone explain why I am able to write to the file that I have set to be read only?