Terminal & built-in storage tools

du -sh * Sorted by Size: The One-Liner That Finds Big Folders on Mac

Your Mac says it has 40 GB of "Other" or "System Data" but gives you no breakdown. The fastest way to start a real investigation is a single Terminal command that measures every folder in a directory and sorts the results from largest to smallest. This article covers the exact incantation, explains each flag, shows why the human-readable sort works on modern macOS, and gives you a saved alias so you never have to remember the syntax again.

The Core Command: du -sh * | sort -rh

Open Terminal (press Command + Space, type Terminal, press Return) and run:

du -sh * | sort -rh

That's it. Run this from any directory and you'll get every item in that folder, sorted from biggest to smallest, with human-readable sizes like 4.2G or 812M.

What each flag does

  • du: disk usage. It walks the filesystem and reports how much real disk space each item occupies (accounting for all nested contents).
  • -s: summarize. Instead of printing every sub-file individually, it gives one total per argument. Without -s you'd get thousands of lines.
  • -h: human-readable. Sizes print as K, M, or G instead of raw 512-byte blocks.
  • *: expand to every visible item in the current directory. Hidden files (dotfiles) are excluded; see below for how to include them.
  • | sort -rh: pipe the output to sort. The -h flag on sort understands human-readable suffixes, so 4.2G ranks above 812M. The -r reverses the order so the biggest items appear first.

Why -h Works on macOS sort (and When It Doesn't)

The -h flag on sort (sometimes called human-numeric-sort) has been part of GNU coreutils for years, but macOS ships BSD userland tools. The good news: macOS Monterey and later include a version of sort that accepts -h. On macOS Sonoma, Sequoia, and Tahoe this command works out of the box with no extra installs.

If you're on an older macOS version or you get an error like sort: invalid option -- h, you have two options:

  1. Install GNU coreutils via Homebrew (brew install coreutils) and use gsort -rh instead of sort -rh.
  2. Use a numeric sort workaround that converts sizes to bytes first (more complex, rarely necessary in 2025+).

On any Mac running a recent macOS release, the plain sort -rh form works correctly. No Homebrew required.

Practical Workflow: Finding the Big Folders

Start at the home directory

The most useful place to begin is your home folder:

cd ~
du -sh * | sort -rh

This immediately shows which top-level folders are consuming the most space: Movies, Downloads, Library, and so on. From there you can drill in.

Include hidden files and folders

The * glob skips dotfiles. To include hidden items, use .[^.]* * or switch to a brace expansion:

du -sh .[^.]* * 2>/dev/null | sort -rh

The 2>/dev/null suppresses "permission denied" messages for folders your user account can't read. This matters in your home directory where some dotfiles are locked by system processes.

Dig into Library

The ~/Library folder is hidden by default but is usually one of the largest contributors. Navigate into it and run the same command:

cd ~/Library
du -sh * 2>/dev/null | sort -rh

Common large subfolders you'll find here:

  • ~/Library/Caches: app caches that can often be cleared safely.
  • ~/Library/Application Support: app data, some of which may belong to apps you've already deleted.
  • ~/Library/Containers: sandboxed app data for Mac App Store apps.
  • ~/Library/CloudStorage: iCloud Drive and other cloud sync folders stored locally.
  • ~/Library/Mobile Documents: another iCloud path worth checking.

Check system-level directories (requires sudo)

Some large folders live outside your home directory. To measure those you need elevated privileges:

sudo du -sh /var/folders/* 2>/dev/null | sort -rh
sudo du -sh /private/var/db/* 2>/dev/null | sort -rh

Use caution here. These are system directories and the sizes are informational. Do not delete contents without knowing exactly what each folder contains.

Save a Shell Alias So You Never Forget the Syntax

The du -sh * | sort -rh command is useful enough to keep at your fingertips. Add a short alias to your shell config so you can type dusort from any directory.

For zsh (the default shell on Apple Silicon and recent Intel Macs)

# Open your zsh config
nano ~/.zshrc

# Add this line anywhere in the file
alias dusort='du -sh .[^.]* * 2>/dev/null | sort -rh'

# Save (Control+O, Return) and reload
source ~/.zshrc

For bash

echo "alias dusort='du -sh .[^.]* * 2>/dev/null | sort -rh'" >> ~/.bash_profile
source ~/.bash_profile

Now any time you navigate to a directory in Terminal, typing dusort gives you an instant ranked breakdown. No flags to remember.

Limitations of du on Mac

The du approach is fast and built-in, but it has real constraints worth understanding before you act on the results.

  • No context on what's safe to delete. du tells you a folder is 8 GB; it has no idea whether deleting it would break an app or lose data.
  • APFS snapshots and Time Machine are invisible. On APFS volumes, local Time Machine snapshots can consume significant space that du doesn't attribute to any visible folder. Check with tmutil listlocalsnapshots / and tmutil thinlocalsnapshots / 9999999999999 4 to reclaim that space.
  • System Data is opaque. Much of what macOS labels "System Data" in About This Mac lives in protected locations that your user account can't fully traverse. You'll see "permission denied" for many paths even with 2>/dev/null suppressing the noise.
  • iCloud placeholders count as zero. Files stored in iCloud but not downloaded locally show their on-disk placeholder size (often just a few kilobytes), not the actual file size. The full picture requires downloading or using a tool that reads iCloud metadata.
  • Hardlinks are counted once per reference. APFS uses hardlinks for certain system files. du may double-count or under-count depending on the traversal path.

Going Deeper: du Across the Whole Disk

To get a full picture of the largest folders anywhere on your Mac, you can run du from the root. This takes several minutes and requires sudo:

sudo du -sh /* 2>/dev/null | sort -rh | head -20

The head -20 limits output to the top 20 entries. From there you can drill into any path that looks unexpectedly large.

A more targeted version scans your home directory recursively and prints the 20 biggest folders at any depth:

du -h ~ 2>/dev/null | sort -rh | head -20

Note: this version drops the -s flag, so du prints every subfolder. Combined with sort -rh | head -20 you get the top offenders across all nesting levels, not just the top-level directories.

When You Want the Full Picture Without the Terminal Work

The du workflow is powerful for targeted investigations, but it requires you to navigate directory by directory and interpret raw output. If you want an automatic ranked view across your entire disk, including caches, app leftovers, and duplicate files, Crumb's largest-items list does this scan automatically and presents results as a reviewable list before anything is removed. It runs entirely on-device with no account needed. Useful as a complement when the Terminal output leaves you unsure what's actually safe to clear.

Reclaim your disk in one click

Crumb audits your whole Mac, tells you what's safe to delete, and frees the space in seconds — private, local, and Apple-notarized.

Download Crumb for macOS

Frequently asked questions

Why does 'sort -rh' not work on my Mac?
The -h flag on sort (human-numeric sort) requires macOS Monterey or later. On older systems the BSD sort does not support it. Install GNU coreutils via Homebrew with 'brew install coreutils' and replace 'sort' with 'gsort' in the command. On macOS Sonoma, Sequoia, and Tahoe it works without any extras.
How do I find the largest folders on my Mac using du, including hidden ones?
Use 'du -sh .[^.]* * 2>/dev/null | sort -rh' from any directory. The '.[^.]*' pattern matches hidden dotfiles while excluding the '.' and '..' directory entries. The '2>/dev/null' part suppresses permission-denied errors so the output stays clean.
What is the difference between 'du -sh *' and 'du -h *'?
The -s flag tells du to summarize each argument as a single total. Without it, du recurses into every subdirectory and prints a line for each one, which can produce thousands of lines of output. For finding large folders quickly, -s is almost always what you want.
Why does 'du' show less space used than About This Mac?
Several factors cause this discrepancy. APFS local Time Machine snapshots consume space that du does not attribute to any visible folder. iCloud files that are not downloaded locally appear as tiny placeholders. System-protected directories return permission errors, so their sizes are excluded from your total. These gaps are a known limitation of navigating storage with du.
How can I save the du sort command as a shortcut in Terminal?
Add an alias to your shell config file. For zsh (the default on modern Macs), open ~/.zshrc and add: alias dusort='du -sh .[^.]* * 2>/dev/null | sort -rh'. Then run 'source ~/.zshrc' to activate it. After that, typing 'dusort' from any directory gives you an instant ranked size breakdown.