Since all hard links to a file on the same file reference, you can change the file a name and then make under a different name watch the changes with:
Code:
techarena @ ~ $ cd echo "hello"> first link
cd changes in your home directory and places the file there first link to the word 'hello'contains. So redirecting the output of echo (echo is only the arguments) in the file first link to.
Code:
techarena @ ~ $ cat first link
Confirmed the contents of first link.
Code:
techarena @ ~ $ ln first link second link
Creates a hard link: second link now points to the same inode as first link.
Code:
techarena @ ~ $ cat second link
Confirmed that second link is the same as first link.
Code:
techarena @ ~ $ ls-l
Note that the number of hard links by first link and second link is 2.
Code:
techarena @ ~ $ echo "change">> second link
This is another shell redirection - do not take care of the details. We have the word "change"to second link attached. Check this with cat second link.
Code:
techarena @ ~ $ cat first link
first link also has the word "changeadded, "since first link and second link on the same file reference. It does not matter how you call the file when you make changes.
Code:
techarena @ ~ $ chmod a + rwx first link
Change the rights for first link. Give the command ls-l one, to see that the rights of second link were also amended. The rights are then stored in the inode, not the links.
Code:
techarena @ ~ $ rm first link
Deletes this link. This is a subtlety of rm - deletes it actually links, not files. Now enter ls-l one and see for yourself from the fact that second link is still there. Note also decreased by a number of hard links from second link.
Code:
techarena @ ~ $ rm second link
Clears the other link. If there are no links to a file anymore, Linux deletes the file itself - this is the inode. All files do so, even special types of files, such as devices (for example / dev / hda). A directory is simply a list of filenames and inode numbers - ie a list of hard links. If you are composing your hard link, you will add a new entry in the list of directories only. If you delete a file, you delete only one hard link from the Directory.
Bookmarks