Skip to content
Codescope

Inodes, hard links & symlinks

A filename is not the file. It is a directory entry pointing at one.

core9 min6 steps

Before you start

A filename is not a file. On Linux, a filename is an entry in a directory that points at an **inode** — a numbered record that carries the actual metadata (size, permissions, owner) and the addresses of the file's data blocks.

This split is why one file can have many names (**hard links**), why deleting a filename does not always free the data, and why mv inside a filesystem is nearly free — nothing is copied, just directory entries changed.

This lesson visualises the inode behind a file, adds a second hard link, adds a symlink, and shows what "deletion" actually does.

Directory: /home/ana

a directory is a list of name → inode pairs
Rownameinode
notes.txt4218

Inode table

the file itself — metadata and where the data lives
inode 4218link count 1
mode/owner/size
rw-r--r-- ana 1024
data blocks
→ disk blocks

One name, one inode, link count 1.

Step 1 of 6. The file is the inode, not the name. An inode holds everything about a file except its name: permissions, owner, size, timestamps, and pointers to the data blocks on disk. A directory is simply a table mapping names to inode numbers. `ls -li` prints that number.

01 / 06

Step 01 / 06

The file is the inode, not the name

An inode holds everything about a file except its name: permissions, owner, size, timestamps, and pointers to the data blocks on disk.

A directory is simply a table mapping names to inode numbers. ls -li prints that number.

session.shShell
ls -li notes.txt          # -i shows the inode numberln notes.txt hard.txt     # hard link: a second nameln -s notes.txt soft.txt  # symlink: a file containing a pathrm notes.txt              # hard.txt still works, soft.txt breaksdf -i                     # inodes can run out before disk space does