chevron_left
399 points
8 4 3

Difference between softlink and hardlink in linux

 
symbolic link, also termed a soft link, is a special kind of file that points to another file, much like a shortcut in Windows or a Macintosh alias. Unlike a hard link, a symbolic link does not contain the data in the target file. It simply points to another entry somewhere in the file system.

symbolic or soft link is an actual link to the original file, whereas a hard link is a mirror copy of the original file. If you delete the original file, the soft link has no value, because it points to a non-existent file. But in the case of hard link, it is entirely opposite. Even if you delete the original file, the hard link will still has the data of the original file. Because hard link acts as a mirror copy of the original file.

In a nutshell, a soft link

 

  • can cross the file system,
  • allows you to link between directories,
  • has different inode number and file permissions than original file,
  • permissions will not be updated,
  • has only the path of the original file, not the contents.

A hard Link

  • can't cross the file system boundaries (i.e. A hardlink can only work on the same filesystem),
  • can't link directories,
  • has the same inode number and permissions of original file,
  • permissions will be updated if we change the permissions of source file,
  • has the actual contents of original file, so that you still can view the contents, even if the original file moved or removed.

    The main advantage of hard links is that, compared to soft links, there is no size or speed penalty. Soft links are an extra layer of indirection on top of normal file access; the kernel has to dereference the link when you open the file, and this takes a small amount of time

More Posts

Difference between static and dynamic in java Sanjana Sagar - May 29
Difference between abstract and interface in java Sanjana Sagar - May 28
Difference between abstract and interface in java Sanjana Sagar - May 28
Difference between dbms and rdbms in tabular form Sanjana Sagar - May 28
Difference between class and id attribute in html Sanjana Sagar - May 28
What is the difference between id and class in css Sanjana Sagar - May 22
Difference between class and method in java Sanjana Sagar - May 20
What is the difference between abstraction and encapsulation in java Sanjana Sagar - May 20
what is the difference between char and varchar? Being human - Jun 8
What is the difference between ascii and unicode Sanjana Sagar - May 28