Pcornel
Browse topics
Options
Recent
Favorites
Linux · Technical reference

Hard Links

Direct answer

A hard link is another directory entry for the same inode. All names are equal; the data is freed only when the last link is removed and no process has it open.

When to use this

Use it to understand why deleting a file did not free space, or when backup tools treat linked files specially.

First 30 seconds

1. ls -li <file> — inode number and link count.

2. Link count > 1 → find <mount> -samefile <file> lists the other names.

3. Removing one name does not free space until all are gone.

4. Backups: use rsync -H to keep hard links.

5. Verify with df -h after cleanup.

Operational verification

file created (link count 1) → ln adds another name for the same inode → each rm removes a name → data freed at 0 links

Evidence · next step

For Filesystem → Hard Links, continue with the first unproven Topic check: Compare device/filesystem plus inode number and link count for the candidate names. If that boundary is healthy, advance to the adjacent check: Confirm both names are within the same filesystem before attempting link semantics. Preserve the same host/time/identity scope and rerun the original workload before accepting recovery.

Continue only after interpreting the current observation.
Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
linux
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

Platformlinux
Scope / prerequisiteUse it to understand why deleting a file did not free space, or when backup tools treat linked files specially.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

5 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Operational evidence path Verify boundary

filesystem namespace → directory entry A/B → same filesystem-local inode → shared metadata/data → link/open reference count → consumer path use

Healthy evidence: candidate names resolve on the same filesystem to the same inode with expected link count and shared content/metadata behavior.

Step 2 Verification and output interpretation Verify boundary

Existing fast checks for this Topic. - Compare device/filesystem plus inode number and link count for the candidate names.

  • Confirm both names are within the same filesystem before attempting link semantics.
  • Track remaining links and open handles before predicting data reclamation.
  • Verify application behavior under each pathname if name/location has semantic importance to the consumer.

Verification chain. filesystem namespace → directory entry A/B → same filesystem-local inode → shared metadata/data → link/open reference count → consumer path use

Step 3 Commands Verify boundary
ln file hardlink
ls -li file hardlink
find / -samefile file 2>/dev/null
Step 4 Failure modes and next checks Narrow the fault

Suspicious evidence: hard links are treated as independent copies, cross-filesystem linking is expected, or removing one name is assumed to free the data immediately.

Step 5 Common mistakes Narrow the fault
  • Expecting hard links across filesystems or to directories.
Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points

Hard links cannot cross filesystems or point to directories. ls -l shows the link count; find -samefile finds all names. Editing through any name changes the same data.

Key checks
  • ls -li <file> — inode and link count
  • find <dir> -samefile <file> — every name of the same inode
  • ls -ld <path> — owner, permissions and type
  • stat <path> — inode, links, size and timestamps
  • df -h <path> — filesystem and free space
  • findmnt <path> — which mount the path is on
ReferenceWhat it is1 section · depth on demand

Core model

Show same-filesystem identity by comparing filesystem/device plus inode and link count, then reason about namespace names separately from the shared object metadata/content. Normal hard links to directories are restricted to protect hierarchy consistency.

ReferenceImportant terms & boundaries5 sections · depth on demand

What this shows and what it does not

Matching inode identity shows shared underlying object, not that applications treat the different pathnames identically or that data is released when one name is removed.

In depth

Hard links

A hard link is an additional directory entry for an existing inode. The symlink(7) manual page states that a hard link is indistinguishable from the original file. Every name refers to the same inode, so there's no "original" and "copy". The page also sets the limits:

  • Hard links can't refer to directories.
  • They can't cross file system boundaries, because inode numbers are only unique within one file system.

The inode(7) manual page adds that the inode keeps a link count. The data is only freed when the last name is removed and no process has the file open.

Hard links compared with copies and symlinks

Hard linkCopySymbolic link
Separate inodeNoYesYes (its own small inode)
Changes visible through every nameYesNoYes
Survives deleting the "original" nameYesYesNo (dangling)
Across file systemsNoYesYes
To directoriesNo—Yes
Extra disk spaceNoneFull sizeA few bytes

Where hard links are used

UseExample
Snapshot-style backupsrsync --link-dest: unchanged files are hard links to the previous backup
Directory entries . and ..Why a directory's link count is 2 + its number of subdirectories
Package systems and storesDeduplicating identical files
Atomic replacementWrite a new file, then ln -f or mv it into place
host$ echo "v1" > report.txt
host$ ln report.txt report-hardlink.txt
host$ ls -li report*
1051234 -rw-r--r-- 2 alice alice 3 Nov 28 11:30 report-hardlink.txt
1051234 -rw-r--r-- 2 alice alice 3 Nov 28 11:30 report.txt
host$ rm report.txt; cat report-hardlink.txt
v1
host$ ln /srv/data/big.iso ~/big.iso
ln: failed to create hard link '/home/alice/big.iso' => '/srv/data/big.iso': Invalid cross-device link
host$ find /srv/backup -samefile /srv/backup/2026-11-28/etc/hosts | head -3
host$ rsync -a --link-dest=/srv/backup/2026-11-27 /etc/ /srv/backup/2026-11-28/etc/

Reading the example

Both names show the same inode number (1051234), and a link count of 2. Removing one name leaves the data reachable through the other. find -samefile lists every name for one inode, which shows how many daily backups share an unchanged file.

Documented example, not captured output.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

How it works at runtime

Hard Links is part of Filesystem → Hard Links. Hard Links are multiple directory entries within the same filesystem that reference the same inode; all names are peers for the same underlying object, and removing one name does not remove the data until the final link and open references are gone.

Topic-specific state model. Hard Links are multiple directory entries within the same filesystem that reference the same inode; all names are peers for the same underlying object, and removing one name does not remove the data until the final link and open references are gone.

Interpretation rule. - Hard link ≠ copy; linked names reference the same inode/data.

  • Deleting one hard-link pathname ≠ deleting the underlying file when other links remain.
  • Hard links normally cannot cross filesystem boundaries.
  • Permissions/ownership are inode metadata shared by all hard-link names, not independent per pathname.

Quick reference

Hard links are extra directory entries for the same inode (same filesystem only, not for directories). The data is freed when the link count reaches zero and no process holds the file open.

ln original.txt hardlink.txt
ls -li original.txt hardlink.txt      # same inode number, link count 2
find . -samefile original.txt

Backup tools use hard links for space-efficient snapshots (rsync --link-dest, cp -al). Editing tools that write a new file and rename it break the link (the other name keeps the old content).

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.

Limits and how it fails

Primary failure point. Matching inode identity shows shared underlying object, not that applications treat the different pathnames identically or that data is released when one name is removed.

ReferenceConfiguration & state1 section · depth on demand

Configuration, persistence and lifecycle

Distribution/platform context. Hard Links owns same-inode multi-name semantics. Command syntax belongs to File & Directory Management; permissions and application path behavior remain separate.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor doclinux current

Authoritative/upstream documentation reviewed for bounded claims in Filesystem → Hard Links. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Terminology layer

Terms & aliases

Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.

Aliases that resolve here
linux hard linkshard link inodemultiple filenames same inodelink count linux
Embedded reference data

Quick lookup tables

Hard Links operational reference

Topic-specific lookup boundaries, proof limits and next-step Evidence for Hard Links.

Lookup boundaryTopic-specific referenceOperational use
Scope / effective stateHard Links are multiple directory entries within the same filesystem that reference the same inode; all names are peers for the same underlying object, and removing one name does not remove the data until the final link and open references are gone.Establish exactly what this Topic owns before crossing into another subsystem.
Fast verificationPin process/container mount namespace → resolve the exact path from / and record every mount crossing → identify final dentry + filesystem/device + inode + file type → capture ownership/mode/ACL and capacity where relevant → map pseudo/device/runtime objects to the live kernel/process endpoint → verify the original consumer read/write/execute/service result.Use the shortest evidence path first; a fast check is a boundary test, not blanket proof.
Verification chainfilesystem namespace → directory entry A/B → same filesystem-local inode → shared metadata/data → link/open reference count → consumer path useTrace requested/configured state through effective state to the observed workload result.
Failure boundaryMatching inode identity proves shared underlying object, not that applications treat the different pathnames identically or that data is released when one name is removed.Stop broad troubleshooting at the first boundary that is not supported by evidence.
Positive evidenceCorrelated namespace, path and object evidence can establish this Linux Filesystem proof path: filesystem namespace → directory entry A/B → same filesystem-local inode → shared metadata/data → link/open reference count → consumer path useUse this observation only for the specific claim it actually supports.
Evidence limitIt does not independently prove behavior outside the captured namespace, mount, inode/object, authorization, backing-resource or consumer scope. Matching inode identity proves shared underlying object, not that applications treat the different pathnames identically or that data is released when one name is removed.Do not promote a local success signal into end-to-end or adjacent-dependency proof.
Next troubleshooting checkContinue from the first unproven boundary: preserve the same process mount namespace, resolve the path and mount crossings, identify the exact object/inode or live pseudo/device endpoint, inspect effective access/capacity, then repeat the original consumer operation before changing unrelated filesystem state.Continue to the next unresolved boundary while preserving the original test condition.

Hard Links · operational reference

Compact Linux state, persistence, verification and boundary reference for fast lookup.

Reference boundaryHard Links
Topic pathFilesystem → Hard Links
Runtime stateHard Links are multiple directory entries within the same filesystem that reference the same inode; all names are peers for the same underlying object, and removing one name does not remove the data until the final link and open references are gone.
Fast checks- Compare device/filesystem plus inode number and link count for the candidate names. - Confirm both names are within the same filesystem before attempting link semantics. - Track remaining links and open handles before predicting data reclamation. - Verify application behavior under each pathname if name/location has semantic importance to the consumer.
Verification chainfilesystem namespace → directory entry A/B → same filesystem-local inode → shared metadata/data → link/open reference count → consumer path use Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return/regression → explicit Evidence boundary. Boundary chain: local authoritative state → adjacent dependency → effective/programmed state → original workload/request → return path or regression → explicit Evidence boundary.
Failure boundaryMatching inode identity proves shared underlying object, not that applications treat the different pathnames identically or that data is released when one name is removed. Boundary chain: process credentials/namespace → path/mount lookup → DAC/ACL/LSM → filesystem metadata → block/device/backend → completion/read-back.
Persistence ruleProve which configuration source owns the state, then prove that the running consumer loaded or generated the intended state.
Confirmation

Confirm action

Continue?