Find the 20 largest files and folders here
Build a paste-ready command, then review its compatibility and effects before running it.
du -ah . | sort -rh | head -20read-onlyno known side effects Compatibility
Linux + macOSVerified for Linux, macOS using posix, bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsdudu must be installed and available on PATH.
Version supportdu Current supported releasesVerified for linux, macos using posix, bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals4.8G .Representative successful output; values vary with the selected target and system state.
Known errorsdu: command not founddu is missing or is not available on PATH.
Verifydu -ah . | sort -rh | head -20The output matches the expected target and exits without an error.Rollback noteNot required: this command is read-only and does not change system state.
Command breakdown
01du -ah .Measure everything hereCalculates sizes for all files and folders (-a) using readable units (-h), starting at the current directory (.).
02|PipePasses every measured path to the sorter.
03sort -rhLargest firstSorts in reverse order (-r) while understanding human-readable units (-h).
04|PipePasses the ordered list to the final command.
05head -20First twentyShows only the twenty largest entries.
Example input
du -ah . | sort -rh | head -20
Example output
4.8G .
2.1G ./backups
1.4G ./backups/db-2026-07-22.sql.gz
812M ./logs
406M ./logs/app.log
Illustrative output — exact values vary by system and data.
Runbooks
Official sources