Here are the differences between hard link and soft link in Linux. Below, you will find examples of how to create them.

Hard link Vs Soft link
linux hard link vs soft link
Photo by Mike Bird on Pexels.com

Table of contents

  1. Soft (Symbolic) link
  2. Hard link
lrwxrwxrwx 1 root root   11 2018-08-11 07:34 libc.so.6 -> libc-2.6.so

The beginning first letter ‘l’ says it is a link (symbolic). The soft link’s purpose is to use the same file in multiple places. That reduces your coding time.

For instance, a program needs a file named foo, but foo has frequent version changes. If we do not make it shared, it is hard to track down which version of the file is being used. In this scenario soft link I’d helpful.

Code to create soft link

ln -s source_file symbolic_link

Example of Soft link

Here’s a way to create hard and soft links in Linux

While we are on the subject of links, we need to mention that there is a second type of link called hard links. Hard links also allow files to have multiple names, but they do it differently.

Precisely, a hard link acts using a file with a different name. And the resource (source) is not sharable. It is the opposite in the case of symbolic link – That means the resource is sharable. to create the Hard link

Code to create hard link

ln orginal_file_path new_file_path

Example of hard link

Related