Hard Link -> Where a file has two names and both the names points directly to the blocks on the disc that contain the data.
Suppose if a file file1.txt already exist and you want to give it another name file2.txt then use command :
ln file1.txt file2.txt
The above command creates a hard link.
The only way you should be able to distinguish whether there is a link or its a normal file is by doing ls -l. The second column tells you how many links are there for the particular block of data on disc.
To know what's linked to it use ls -i which will give you information of what is linked to what.
Symbolic or Soft Link -> Where a file has one main name and other names as well by which this can be referred. It is relatively slow than a hard link but more flexible.
You can setup symbolic links in the same way you setup Hard links.. the only difference is that you use a -s parameters to specific whether this is a symbolic link or not.
For e.g., ln -s file1.txt file2.txt
The above creates a symbolic link with file1.txt as the main file name. To know if it is a symbolic link or not do ls -l and if the first column displays an "l" you can be sure that it is a symbolic link.
Diagramatically Hard and Symbolic links can be explained as:-
No comments:
Post a Comment