linuxlab.io
Tutorials▾
  • Linux & networking
    File system, processes, TCP/IP, BGP and OSPF
    →
  • Terraform & IaC
    HCL, state, plan/apply on a LocalStack sandbox
    →
  • Git & GitHub
    Object model, plumbing, branching, GitHub Actions
    →
All tutorials →
PricingAboutSign inCreate account
/
  • Introduction
  • Lessons
  • How it works
  • Simulator
  • Knowledge base
  • Interview prep
Index
Categories
All entries
Footer
linuxlab-TutorialsPricingAboutPrivacy & cookies
Copyright © 2026 LinuxLab. All rights reserved.
home/linux/kb/File system/hard-link

kb/filesystem ── File system ── beginner

Hard link

Hard link is a second name for the same [[inode]]. Both names are equal: the file lives as long as at least one of them exists.

view as markdownaka: hardlink, hard-links

What a hard link is

The command ln src dst (no flags) creates a hard link, a new entry in the directory that points to the same inode as src. After that:

  • src and dst have the same inode number (ls -i shows it)
  • stat on both reports Links: 2 (the number of names went up)
  • changes made through either name are visible through the other; it is one file
  • rm src leaves the file intact: the blocks are freed only when the last name is gone

Limits

A hard link can only be made within one filesystem, since an inode is local to a specific FS. And only to regular files: a hard link to a directory is forbidden (it would break the acyclic structure of the file tree; . and .. are the exception).

For cross-filesystem references and links to directories, use symbolic-link.

Where you meet it in practice

  • Snapshot backups (rsync --link-dest): between backups, unchanged files keep hard links to each other, which saves a huge amount of space byte for byte
  • Deduplication in /usr/share/doc and Docker layer images (on ext4)
  • Atomic publishing: ln new staging followed by mv -T staging old guarantees that at any moment old points to either the old or the new content, with no in-between state

§ команды

bash
ln a.txt b.txt && ls -li a.txt b.txt

Create a hard link and confirm both share one inode

bash
stat a.txt

The Links field shows how many names point to this inode

bash
find . -inum 12345

Find every name that points to a specific inode

§ см. также

  • inodeInodeAn inode is a filesystem record that holds metadata and pointers to a file's data blocks. The filename lives separately, in a directory, and simply points to the inode.
  • symbolic-linkSymbolic linkA symlink is a separate shortcut file that stores a path to its target. Unlike a [[hard-link]], it has its own [[inode]], and a symlink can point at anything, including something that does not exist.
  • fhsFilesystem Hierarchy Standard (FHS)FHS is the standard for what lives in which Linux root directory: /etc holds config, /var holds changing data, /usr holds the distro's static files, /home holds users, /tmp holds temporary files.

§ упоминается в уроках

  • ›beginner-02-files-and-text
  • ›beginner-03-inodes-and-links
Footer
linuxlab-
Copyright © 2026 LinuxLab. All rights reserved.
Tutorials
Pricing
About
Privacy & cookies