Difference Between Hard Link and Soft Link (Symbolic Link) in Linux


Creation:

The ln utility is used to create hard links and (with the -s option) soft links, also known as symbolic links or symlinks. These two kinds of links are very useful in UNIX-based operating systems.

Suppose that file1 already exists. A hard link, called file2, is created with the command:

$ ln file1 file2

Soft (or Symbolic) links are created with the -s option, as in:

$ ln -s file1 file3

Differences

  1. In case of Hard Links both files have same inode number as compare to Soft Links which have different inode numbers.
  2. Symbolic links take no extra space on the filesystem (unless their names are very long). They are extremely convenient, as they can easily be modified to point to different places. 
  3. Unlike hard links, soft links can point to objects even on different filesystems, partitions, and/or disks and other media, which may or may not be currently available or even exist. In the case where the link does not point to a currently available or existing object, you obtain a dangling link.

 

 

 

Tags

#buttons=(Accept !) #days=(20)

Our website uses cookies to enhance your experience. Learn More
Accept !