Skip to content
WHFS Headroom

TA-04 · Tools & Apps

Checking folder sizes in Terminal with du and df

Monochrome paper tape strip unfurling across dark wooden desk beside mechanical calculator keys
Text measurement predates pretty graphs and still wins arguments: typed lines settle disputed gigabytes.

Graphical dashboards summarize; command lines testify. Whenever storage disputes need settling precisely, which folder swelled, which volume lies, du and df deliver sworn statements every macOS ships with, needing neither installs nor licenses nor patience beyond typing aptitude ordinary keyboards supply generously.

df: the volume witness

df -h inventories mounted filesystems in human units, columns declaring size, consumed, remaining percentages. Append target paths narrowing focus, e.g., df -h /System/Volumes/Data, isolating user-relevant partitions besides read-only realms confusing newcomers encountering multiple rows unexpectedly. Run twice spacing minutes apart, noting movement; discrepancies observed live resolve suspicions concerning phantom usage credited mysteriously within purgeable accounting quirks elsewhere discussed thoroughly enough spare repetition presently.

du: the tree clerk

Whereas df testifies volumes, du itemizes branches: du -h -d 1 ~/Downloads prints immediate children weighted totally beneath. Raise depths descending floorward gradually rather than drowning initially; spotlight suspects further via plain directory invocations hitting exact nodes queried. Root-wide sweeps chug considerably longer against cavernous homes, mornings even; schedule accordingly while coffee brews cheerfully nearby without resenting thoroughness meanwhile.

Flags earning keep

  • -h translates bytes humanely throughout outputs cherished universally;
  • -d caps recursion depth preventing avalanches unmanageable otherwise;
  • -x restrains crossings beyond mount boundaries, keeping homework localized tidily;
  • -g forces gigabyte uniformity easing spreadsheet transfers undramatically but reliably weekly.

Combine judiciously e.g., du -hx -d 2 /Users, surveying household totals compartmentally minus counterfeit extras injected cross-volume accidentally amid turbulent mounts encountered periodically.

A worked pair worth memorizing

The desk's standard opening pair reads, verbatim: df -h /System/Volumes/Data then du -hx -d 1 ~. The first line certifies the stage; the second ranks your home's main rooms in one screen. Between them, most "where did my space go" mysteries resolve before coffee cools, and any residual suspect earns a targeted du at greater depth. Copy the pair into a note once and reuse it forever; there is no shame in commands that work repeated verbatim, only in retyping them from memory badly under pressure. Numbers first, drama never; that is the whole tradition this desk inherited and refuses to retire.

Two accounting quirks surprise newcomers. Directories you cannot read print as zero rather than an error, so rerun a suspect quietly and treat its silence as permission, not absence. And totals add differently depending on scope: hard links, sparse files and crossed mount boundaries can make one file count twice along separate paths. When numbers disagree across two invocations, change only the scope between runs and compare again.

From numbers to decisions

A du table earns its keep when it changes what happens next. Copy the largest lines into your worksheet beside the df figures taken at the start, then act on them through the order set out in the master cleanup sequence. The same habit of writing findings down pairs naturally with the large-file log, and blank sheets wait on the field kit page for exactly this purpose.

Two du habits that prevent arguments later

First, quote depth explicitly whenever sharing output with anyone else: a bare human-readable listing of the root implies unbounded recursion, and someone will read six screens of it as six separate problems. Second, date every capture pasted into notes or tickets, because volumes move hourly and yesterday's giant is tomorrow's rounding error. Screenshots without timestamps and terminal runs without paths produce disputes rather than diagnoses; two typed characters preventing either earns its place among habits this desk considers professional-grade, however casual the household keeping them.

A closing caution about trust

Terminal output has one property dashboards lack and readers should price correctly: it shows exactly what was asked, with no smoothing layer interpreting on your behalf. That honesty cuts both ways. du will happily mislead a hurried reader who forgets which directory they stood in, while df never once volunteered why availability shifted. Commands respect precision, never intentions. Pair them with the written baselines this desk keeps recommending and the combination outperforms any single window on the machine, graphical or otherwise, without requiring faith in anyone's summaries, ours included.

Neighbors on this shelf