Friday, March 11, 2011

Hard Link and Soft Link



All the files have a data structure called i-node which stores the information about the file. We use the name of the file to refer to the i-node of the file. Link is a way to refer the data in a file. There are 2 types of links which are mentioned below.

Hard Links:

1. Hard link is a pointer to files inode.

2. Original file and hard link will have the same i-node number.

3. Hard link can be used only to link the files and not the directory.

4. If we remove the original file, then also hard link file will be there.

5. Hard link can span only within the filesystem.

6. The command to create hard link is,

#ln sourcefile destinationfile

Soft Links:

1. Also known as symbolic link is a file containing the name of another file.

2. Original file and the soft link file will have different i-node number.

3. Soft link can be used to link both files and directories.

4. If we remove the original file, then there will not be any use with the link.

5. Soft link can span across different file systems.

6. The command to create the soft link is,

#ln –s sourcefile destinationfile

No comments: