Find the largest files in a directory

Read-only
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Locates the files consuming the most disk space under a directory, so you can decide what to archive or delete when space runs low.

filesdisksizecleanup

Parameters

Directory to search under.

How many of the largest files to show.

Commands

List the largest files with human-readable sizes, biggest first

find "." -type f -exec du -h {} + | sort -rh | head -n 20

Verification

du -h "." | tail -n 1

The directory total is consistent with the large files listed.

Undo

Not undoable

This recipe only reads file sizes and changes nothing.

Pitfalls

  • Files you cannot read are skipped silently; run with elevated privileges to include them.
  • du reports disk usage (block-aligned), which can differ slightly from logical file size.

Related