← Mac Change Notes

Why Mac du Counts Hard Links Only Once

Mac’s du counts a hard-linked file once per execution. To measure folders together, pass them to one /usr/bin/du -sk command. Separate invocations can each count the shared file, so adding their totals can overcount it.

In this article

This explains a puzzling result: a folder can report a substantial size when measured alone, then a much smaller size when measured beside another folder. Its contents have not necessarily changed. The command’s accounting scope has.

Start with a read-only comparison before deciding that files are missing, a backup is corrupt or a cleanup tool has found extra storage to reclaim.

Compare one scan with two scans

For two folders you own, substitute their actual paths here:

/usr/bin/du -sk "/path/to/A" "/path/to/B"

The -s option asks for a summary per argument. The -k option reports 1024-byte units, making the numbers easier to compare without human-readable rounding. The explicit executable path selects the utility supplied with macOS.

Now compare that with two independent commands:

/usr/bin/du -sk "/path/to/A"

/usr/bin/du -sk "/path/to/B"

Each separate process starts its own accounting. It does not remember which file another invocation already counted. A shell loop that launches du once per folder has the same limitation.

Keep the folder selection, options and observation time consistent. Files changing during a scan or unreadable directories introduce different explanations. Preserve errors instead of hiding them; a partial scan cannot establish the complete total.

One file can have more than one name

A hard link adds another directory entry for the same underlying file. Apple’s archived link system-call manual explains that the names share access to that object. They are not automatically two independent copies.

Apple Developer’s link manual describing two directory entries sharing one underlying object.

Source: Apple Developer — link(2), captured November 30, 2026. The archived definition explains file identity; the measurement below was performed on the current test Mac.

For ordinary files, inspect identity without changing either path:

/usr/bin/stat -f '%N device=%d inode=%i links=%l bytes=%z' "/path/to/A/file" "/path/to/B/file"

Compare device and inode together. Inode numbers identify objects within a filesystem, so a matching inode number on two different devices does not prove a hard-link relationship. The link count tells you how many names refer to that file.

Identical contents or matching byte counts are insufficient evidence. Two independent copies can contain the same bytes. Conversely, two names for the same file can appear in very different folders.

Our hard-link deletion guide covers what happens when a name is removed or replaced. Here, the question is how a measurement counts names that still exist.

Our test: the same 1 MiB file, different totals

On November 30, 2026, we created a disposable fixture on macOS 15.7.5. Folder A contained a random 1,048,576-byte file. We added a hard link to that file in folder B.

Both paths reported inode 71395242, link count 2, and the same byte length. They belonged to the same test filesystem. We used the built-in /usr/bin/du; no application library, backup or personal document was modified.

MeasurementABCombined fixture
Two separate du -sk invocations1024 KiB1024 KiBNot measured together
One invocation, arguments A then B1024 KiB0 KiB1024 KiB across those rows
One invocation, arguments B then A0 KiB1024 KiB1024 KiB across those rows
One scan of their parent folder——1024 KiB
Parent scan with lowercase -l——2048 KiB

The files stayed in place throughout. Reversing the arguments moved the shared file’s accounting from A to B. It did not transfer ownership of the file or remove data from the other folder.

The zero in this small fixture means the later folder contributed no additional counted blocks to that invocation. It does not mean that opening its file would return zero bytes. Real folders can have other files and directory allocation, so your results need not contain a literal zero.

These are observed values from one controlled fixture. They are not a promise about every filesystem, every backup format or a different tool named du.

Lowercase -l changes the question

Apple’s open-source du manual documents the default single count and the option that disables hard-link checks.

To count each encountered hard-linked name in this accounting, use lowercase L:

/usr/bin/du -skl "/path/to/parent"

That produced 2048 KiB for our two names. It did not allocate another copy or increase actual disk consumption. It changed how the report counted the existing names.

Uppercase -L is different: it controls following symbolic links. It is not the switch for counting hard links repeatedly. A symbolic link refers to a path; a hard link is another name for the file itself.

Decide which question you need answered. A combined default scan is useful when shared file identities should count once across the selected tree. Counting every name can help explain a name-by-name inventory, but that larger number must not be presented as uniquely occupied storage.

Keep cleanup decisions separate from the report

Neither column in the test predicts how much free space deleting that folder would recover. If another hard link still names the file, removing one name does not make the underlying data unnecessary.

Likewise, APFS clones are a different sharing mechanism: they have separate file identities even when storage blocks are shared. Hard-link deduplication is not a general measurement of all APFS sharing, snapshots or reclaimable space.

Before comparing totals, record four things: the executable used, the complete argument list, whether there was one invocation or several, and whether -l was present. Keep any read errors alongside those notes.

If the discrepancy instead comes from comparing a folder with *, check how shell expansion omits hidden files. That changes which paths reach the command, independently of hard-link accounting.

The useful conclusion is narrow: two names can expose one file, and a single du execution avoids counting that hard-linked file again by default. Use consistent scans to understand the numbers before treating them as a deletion target.