I was just playing with some basic Unix commands with following operations
- create a file 'one'
- create a link 'two' to 'one' (
ln one two)
- Edit the file 'one' and put words - one, two, three, four on separate lines.
- Checked contents of 'two' - it has the same contents, so far so good.
- Create a soft link 'three' to one. three also has same contents
- Verified the number of links using
- Edited file 'one' and added word 'five' on a separate line.
- Checked that files 'two' and 'three' have the same contents - so far so good
- Edited soft link three (
vim three) and added the word 'six' at the end.
- Checked all the three files now have one to six in words.
Question - I understand if file 'one' gets contents of file 'three'. But why does file 'two' also get them?
If I do
ls -l, I see that files one and two have 28 bytes, whereas file three has only 3 bytes (maybe for six). What is the reason for this?
Now if I remove file 'one', I see that three is still shown to be linked to one, but I cannot
cat three and get error that file does not exist. But then why it is shown in the