What is Hard and Soft Link in Linux and How to Use

Here are the differences between the soft link and hard link in Linux. How to find hard or soft links? Here is a way to find out if the link is hard or soft.

Symbolic link and hard link

Table of contents

  1. Soft (Symbolic) link
    1. How to create Soft (Symbolic) link
    2. Example of Soft link
  2. Hard link
    1. Example of 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.

ln -s source_file symbolic_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

How to create the Hard link

ln orginal_file_path new_file_path

Related

Latest from the Blog

Linux Sed Command: Way to Get Match Criteria

This topic shows to use the sed command in Linux to get a matching string

Author: Srini

Experienced software developer. Skills in Development, Coding, Testing and Debugging. Good Data analytic skills (Data Warehousing and BI). Also skills in Mainframe.