1. hard link and soft link: the best place to get it exactly and the motivation behind its differentiation is : http://www.ugrad.cs.ubc.ca/~cs219/CourseNotes/Unix/commands-links.html
A bit from this site is as follows:
A
link is simply a way to refer to the contents of a file. There are two types of links:
Hard links: a hard link is a pointer to the file's i-node. For example, suppose that we have a file
a-file.txt that contains the string "The file a-file.txt":
% cat a-file.txt
The file a-file.txt
%
Now we use the ln command to create a link to a-file.txt called b-file.txt:
% ls
./ ../ a-file.txt
% ln a-file.txt b-file.txt
% ls
./ ../ a-file.txt b-file.txt
The two names a-file.txt and b-file.txt now refer to the same data:
% cat b-file.txt The file a-file.txt %
If we modify the contents of file b-file.txt, then we also modify the contents of file a-file.txt and vice versa
Soft links (symbolic links): a soft link, also called symbolic link, is a file that contains the name of another file. We can then access the contents of the other file through that name. That is, a symbolic link is like a pointer to the pointer to the file's contents. For instance, supposed that in the previous example, we had used the -s option of the ln to create a soft link:
% ln -s a-file.txt b-file.txt
Let us first add another symbolic link using the -s option:
% ln -s a-file.txt Symbolicb-file.txt.If we change the file
Symbolicb-file.txt, then the file
a-file.txt is also modified.
If we remove the file
a-file.txt, we can no longer access the data through the symbolic link
Symbolicb-file.txt.
The link
Symbolicb-file.txt contains the name
a-file.txt, and there no longer is a file with that name. On the other hand,
b-file.txt has its own pointer to the contents of the file we called
a-file.txt, and hence we can still use it to access the data.
IMPORTANT::::The most significant drawback is that hard links cannot be created to
link a file from one file system to another file on another file system. A Unix file
structure hierarchy can consist of several different file systems (possibly on several
physical disks). Each file system maintains its own information regarding the internal
structure of the system and the individual files on the system. Hard links only know this
system-specific information, which make hard links unable to span file systems. Soft
links, on the other hand, know the name of the file, which is more general, and are able
to span file systems.
No comments:
Post a Comment