2014-02-10 20:27:59 +00:00
# du
2019-02-11 18:00:49 +00:00
> Disk usage: estimate and summarize file and directory space usage.
2021-04-01 16:54:26 +01:00
> More information: <https://www.gnu.org/software/coreutils/du>.
2014-02-10 20:27:59 +00:00
2021-10-21 21:34:54 +01:00
- List the sizes of a directory and any subdirectories, in the given unit (B/KiB/MiB):
2014-02-10 20:27:59 +00:00
2019-02-11 18:00:49 +00:00
`du -{{b|k|m}} {{path/to/directory}}`
2014-02-10 20:27:59 +00:00
2019-02-11 18:00:49 +00:00
- List the sizes of a directory and any subdirectories, in human-readable form (i.e. auto-selecting the appropriate unit for each size):
2014-02-10 20:27:59 +00:00
2019-02-11 18:00:49 +00:00
`du -h {{path/to/directory}}`
2016-01-14 13:46:56 +00:00
2021-08-15 18:59:09 +01:00
- Show the size of a single directory, in human-readable units:
2016-01-14 13:46:56 +00:00
2019-02-11 18:00:49 +00:00
`du -sh {{path/to/directory}}`
2014-02-10 20:27:59 +00:00
2019-02-11 18:00:49 +00:00
- List the human-readable sizes of a directory and of all the files and directories within it:
2014-02-10 20:27:59 +00:00
2019-02-11 18:00:49 +00:00
`du -ah {{path/to/directory}}`
2014-02-10 20:27:59 +00:00
2019-02-11 18:00:49 +00:00
- List the human-readable sizes of a directory and any subdirectories, up to N levels deep:
2014-02-10 20:27:59 +00:00
2019-02-11 18:00:49 +00:00
`du -h --max-depth=N {{path/to/directory}}`
2016-09-10 12:18:28 +01:00
2021-01-31 17:05:18 +00:00
- List the human-readable size of all `.jpg` files in subdirectories of the current directory, and show a cumulative total at the end:
2016-09-10 12:18:28 +01:00
2021-10-11 21:39:51 +01:00
`du -ch {{*/*.jpg}}`
2024-04-28 16:11:25 +01:00
- List all files and directories (including hidden ones) above a certain [t]hreshold size (useful for investigating what is actually taking up the space):
`du --all --human-readable --threshold {{1G|1024M|1048576K}} .[^.]* *`