Hard Links vs Soft Links

Linux has two types of links — hard links and symbolic (soft) links. They both look similar on the surface, but internally they work completely differently. Understanding them requires understanding inodes, which are how Linux actually tracks files.

The Key Insight: Files Are Not Their Names

What is the "real" identity of a file in Linux? The inode. An inode is a data structure that stores a file's metadata (size, permissions, timestamps, data block locations) and has a unique number. The filename is just a human-readable label that points to an inode — it's stored in the directory, not in the inode itself.
$ ls -i hello.txt 1234567 hello.txt ← 1234567 is the inode number $ stat hello.txt File: hello.txt Size: 42 Inode: 1234567 Links: 1 ...

When to Use Which

Hard LinkSymbolic Link
Points toInode directlyFile path (string)
Cross-filesystemNoYes
Link to directoriesNoYes
Breaks if original deletedNo (survives)Yes (dangling)
Common use caseBackup systems, package managersVersioning (python → python3.11), /etc/alternatives

Frequently Asked Questions

What will I learn here?

This page covers the core concepts and techniques you need to understand the topic and progress confidently to the next lesson.

How should I use this page?

Start with the overview, then follow the section links to deepen your understanding. Use the table of contents on the right to jump to specific sections.

What should I read next?

Use the navigation below to continue to the next lesson or explore related topics.