Rank the largest directories one level below a path
Build a paste-ready command, then review its compatibility and effects before running it.
du -xhd 1 <path> 2>/dev/null | sort -hr | head -<count>Complete required fields to copy the generated command.
read-onlyno known side effects Compatibility
LinuxVerified for Linux using bash, zsh syntax.
Operational knowledgereview due 2027-01-19
Requirementsdudu must be installed and available on PATH.
Version supportdu Current supported releasesVerified for linux using bash, zsh syntax; consult compatibility notes for platform-specific differences.
Expected signals12G /varRepresentative 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 -xhd 1 {{path}} 2>/dev/null | sort -hr | head -{{count}}The 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
01duCommandRuns the du stage of this one-liner.
02-xhdOptionConfigures du with the -xhd option.
04<path>ParameterA value supplied in the Fill parameters section.
052>RedirectionRedirects command input, standard output, or error output.
06/dev/nullArgumentPasses /dev/null to du.
07|PipelinePasses the output on the left to the command on the right.
08sortCommandRuns the sort stage of this one-liner.
09-hrOptionConfigures sort with the -hr option.
10|PipelinePasses the output on the left to the command on the right.
11headCommandRuns the head stage of this one-liner.
12-<count>OptionConfigures head with the -<count> option.
This advanced community-curated one-liner combines several stages. Review every option and placeholder before running it.
Example input
du -xhd 1 /var 2>/dev/null | sort -hr | head -5
Example output
12G /var
8.4G /var/lib
2.1G /var/log
640M /var/cache
Illustrative output — exact values vary by system and data.
Official sources