Skip to the workspace
Pebellslearn by building
Working with Files  ›  Capstone Project

Soft Links and Hard Links

Soft Links / Hard Links 15 minA hard link is a second name for the same inode that keeps the data alive, while a soft link stores a path and breaks if that path disappears.

linux / Soft Links and Hard Links

Explore each scene at your own pace.

01 · The rule

The rule

Soft Links and Hard Links

Asha's latest harvest file sits deep inside ~/garden/seasons/2026/, and she's tired of typing that long path. She wants a short name in her home folder that always leads to it. Linux has two kinds of link for this, and they behave very differently when the original file is moved or deleted.

The rule

A hard link is another name; a soft link is a signpost.

To see why, you need one fact: a file's data and its name are stored separately. The data and its details (size, owner, permissions) live in a record called an inode. A directory entry is just a name that points to an inode.

Hard link: a second name for the same inode.

$ cd ~/garden/seasons/2026
$ ln harvest.csv harvest-hard.csv
$ ls -li harvest.csv harvest-hard.csv
1048601 -rw-r--r-- 2 asha garden 181 Jun  4 harvest.csv
1048601 -rw-r--r-- 2 asha garden 181 Jun  4 harvest-hard.csv
  • Both names show the same inode number (1048601), and the link count is 2.
  • Neither name is the "original". Delete one and the data stays, reachable through the other. The data is only freed when the last name is gone.
  • Limits: a hard link can't point to a directory, and it can't cross to a different filesystem (another disk or partition).

Soft (symbolic) link: a tiny separate file that stores a path.

$ ln -s ~/garden/seasons/2026/harvest.csv ~/harvest
$ ls -l ~/harvest
lrwxrwxrwx 1 asha asha 42 Jun  4 harvest -> /home/asha/garden/seasons/2026/harvest.csv
  • The type letter is l, and the arrow shows where it points.
  • It can point to directories and to other filesystems.
  • If the target is moved or deleted, the link is left broken (dangling). It still points to a path that no longer exists.

The argument order is the same as cp: target first, then the new link name.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.