Demystifying the Differences Between Soft Links and Hard Links

I wanted to upload my dot files to a GitHub repository, but they were spread across multiple directories. The solution was to create a link to these files in the Git repository, ensuring that any edits to the main configuration file would be reflected in the linked file.


There are two distinct types of links:

1. Symlink (Symbolic Links), also known as Soft Links:

These links point to the file itself and do not reference memory addresses. When you examine a symlink file, you'll only find the path to the linked file. This means that if you were to copy it to a different machine, it would become non-functional.

2. Hard Links:

A hard link is a file that points to the same memory address as the original file. You could think of it as an exact copy, and any changes made in either file will be mirrored in the other.

Symlink vs. Hardlink

Thus, for our use case, Hard Links is to win.

How to create a Hard Link?

This is simply done using the ln command without adding any options to it.

For example, ln ./TextFile.txt ./HardLinkFile.txt

In case of hard links, if you deleted the original file, the hard link file won't be affected, this is the contrary of soft link files, they will be nonfunctional.

要查看或添加评论,请登录

Khaled Mustafa的更多文章

  • A NATO Phonetics Converter

    A NATO Phonetics Converter

    I have developed a basic C program designed to read input from a file, parse it, and generate output using NATO…

  • Bit-Banding

    Bit-Banding

    What is Bit-Banding? It is a feature in the ARM processors that provides a safe and fast way to change a single bit in…

  • C compilation process - An introduction

    C compilation process - An introduction

    Introduction Knowing what goes on behind the scenes when we compile our code. The compilation process Overview of the…

    2 条评论

社区洞察

其他会员也浏览了