Talk:LPI Linux Certification/Create And Change Hard And Symbolic Links

Hard links - more info
The text "When removing a link name, use rm. Only the link will be removed not the linked file." is correct, but I think it ought to be stated that a hard link is no different to the original file entry so that if the last hard link (link count = 1) is removed to a file there no longer remains a way to access the file. So whilst the text is fine for symbolic links, it could be misleading about hard links - possibly leading to loss of data.

I would therefore suggest:

1. appending to


 * "The default links are hard links (ln without an option). A hard link can only be created to an existing file on the same physical device, after creation no visible association can be displayed between a link name and a file name."

the following:


 * "The hard link is an entry in the directory pointing to an i-node in the file system. It is not any different to the original directory entry pointing to the same i-node that was created when the file (i-node) was created.  Neither the new hard link nor the original is primary."

and then after


 * "When removing a link name, use rm. Only the link will be removed not the linked file."

append


 * "However, when the last hard link to a file is removed (i.e. the last directory entry which points to the i-node), access to the file will be lost and the file will be orphaned in the file system."

Although it is already stated "A hard link can only be created to an existing file on the same physical device . . ." and this statement is both brief and correct, it is possible that this might not be interpreted with the fullness of it's meaning. That is, the reader's attention might be focussed on the words, "existing" and "on the same physical device" and s/he might miss the fact that the statement says "a hard link can only be created to a . . . file". I would therefore suggest that a note such as the following be added somewhere on the page.


 * "Hard links can only be made to files not to directories. However, because a symbolic link is itself a type of file stored in the file system, a hard link can be created to a symbolic link that is itself a link to a directory. The hard link will behave in exactly the same way as a hard link to a file.  That is, neither the hard link nor the original directory entry for the symbolic link is primary - they are both hard links to a file which is a symbolic link - and if the final hard link is removed access to the (symbolic link) file will be lost.


 * Of course, the same rules apply: the symbolic link must be in the same file system as the hard link to it, but the target of the symbolic link can be in another file system.


 * After creating the hard link to the symbolic link to the directory, you can change directory to the original directory, the original symbolic link to the directory or to the new hard link to the symbolic link and your pwd will be appropriately different in each case.


 * E.g.

"

My reasons for not simply editing the page are:

1. My unix experience is mostly from about twenty years ago and I might be out of date or have misremembered something.

2. The page is very clean and simple as it is and although, to me it lacks some necessary content, putting all the above in would make it far more cluttered.

I therefore make this as a suggestion for other more experienced wiki editors to look at first and comment on.

Hedles (discuss • contribs) 15:49, 16 February 2013 (UTC)