What’s the difference between Hard Links and Symbolic/Soft Links?

Diego Jeanluck Linares Castillo
3 min readFeb 6, 2022

Before to talk about links we’ve to talk about Inode (Index Node).

Inode Representation
Inode Representation

A very shallow summary about “Inode”

The linux filesystem is based in Inode entries and the Inode holds all metadata about the regular files, directories, or any other object that the file system may contain.

The filenames are in a separate index and linked to the Inode, in this way we can create hard link files and give files more than one name.

Hard Links

Hard Links representation
Hard Links representation

A hard link is a refference or pointer to a file in a filesystem.

Hard links associate two or more files sharing the same Inode. This makes each hard link an exact copy of the rest of the associated files, both data and permissions, owner.

If you delete the original file unlike soft/symbolic links, hard links preserve the data, that’s why the hard links are the same size.

Although called differently, both hard links and the original file offer the same functionality. When modifying the data pointed to by any of them, the real data stored on disk is changed, being modified equally for all.

Characteristics:

  • Same Inode number that the original file.
  • Same file size.
  • Different name of the same file.
  • Have the same permissions.
  • Different of one copy.
  • If you change the permissions of the or the original file this changes will be applied for both or more if you have more hard links.
  • If you modify the original file or the hard link the modify will be apllied for both or more if you have more than one hard link.

How to create a Hard Link:

$ ln  [original filename] [link name]

What does a hard link look like:

They look the same.

-rw-rw-rw- 2 root root (date) original_file.txt-rw-rw-rw- 2 root root (date) hardlinked.txt

Soft Links

Soft Links representation
Soft Links representation

The soft/symbolic links are pointers to another file, you can have more than one soft/symbolic links pointing to a same file, if you delete the principal/original file all the soft/symbolic links are become useless.

Characteristics:

  • Is like a shortcut in windows.
  • Is a pointer to the original file.
  • Each symbolic/soft link have a diferent Inode number.
  • The symbolic links have a less size than the original/principal file.
  • The soft links have all permissions.

How to create a Soft/Symbolic link

$ ln -s [original filename] [link name]

What does a hard link look like:

They look this way.

-rw-rw-rw- 1 root root (date) original_file.txtlrwxrwxrwx 1 root root (date) softlinked.txt -> original_file.txt

--

--

Diego Jeanluck Linares Castillo

Autodidact | Passionate about technology | Holberton School Student