link-count · shipping · also hard-link count, st_nlink, stx_nlink

Link count

A link count is filesystem metadata reporting the number of hard links to an object, subject to filesystem-specific counting conventions.

Related Observatory article: Read on hesela.com

Meaning: Linux exposes the hard-link count as st_nlink in stat results and stx_nlink in statx results. It counts links, not processes, open descriptors or independent copies. The count does not identify the names that refer to the file. [1]

Lifetime: For ordinary local Linux files, removing the final hard link can leave an open file usable through an existing descriptor. A zero link count therefore does not establish that the file is no longer in use, that its blocks have been reclaimed or that its data has been securely erased. Network-filesystem behavior needs separate qualification. [2]

Observation: stat() follows a final symbolic link, whereas lstat() reports the link object itself; fstat() reports the object selected by a descriptor. Choose the object before comparing counts. Linux also warns that different stat fields can describe different moments during a call. A multi-file inventory needs its own consistency boundary; matching counts alone cannot identify matching hard-link groups. [3]

Directories: Do not treat the link count as a portable count of child entries. The ext4 on-disk documentation describes DIR_NLINK using i_links_count = 1 when the directory's hard-link count is not known. This is a directory-count convention, not evidence that a regular file has only one name. [4]

Relations

related
Hard link, Inode, Unlink, Directory

Advantages

  • Helps describe namespace linkage when the filesystem supplies an exact count and the observation scope is controlled.

Limitations

  • Equal link counts do not prove equal hard-link relationships or independent backups.
  • A count does not enumerate names or measure open references; directory conventions can differ from regular-file counting.

Citations

Sources & caveats
  • Primary-source synthesis of Linux man-pages and ext4 format documentation; no new filesystem, recovery or large-directory experiment was performed.
  • The inventory and backup-acceptance guidance is an engineering inference, not a claim that stat provides an atomic snapshot.
  • Human context: https://hesela.com/analyses/backup-verification-is-not-a-restore-test/#link-count-observation

JSON: /data/terms/link-count.json

Published by Hesela team · Updated

Report a correction · Editorial standards · Reuse guidance

Cite this page
Hesela team. Link count. Hesela. 2026-11-15. https://hesela.dev/terms/link-count/