du's Examples

To list the sizes of a directory and any subdirectories in the given unit (B/KB/MB)

du -b|k|m path/to/directory

To list the sizes of a directory and any subdirectories in human-readable form (i.e., auto-selecting the appropriate unit for each size)

du -h path/to/directory

To show the size of a single directory, in human-readable units

du -sh path/to/directory

To list the human-readable sizes of a directory and of all the files and directories within it.

du -ah path/to/directory

To list the human-readable sizes of a directory and any subdirectories, up to N levels deep

du -h --max-depth=N path/to/directory

To list the human-readable size of all .jpg files in subdirectories of the current directory and show a cumulative total at the end

du -ch */*.jpg

Use -a option for printing all files including directories.

du -a -h

Use -c option to print total size

du -c -h

To print sizes till particular level, use -d option with level

du -d

Get summary of file system using -s option

du -s

Get the timestamp of last modified using --time option

du --time

write counts for all files, not just directories

-a, --all

use SIZE-byte blocks

-B, --block-size

equivalent to '--apparent-size --block-size=1'

-b, --bytes

produce a grand total

-c, --total

dereference only symlinks that are listed on the command line

-D, --dereference-args

summarize disk usage of the NUL-terminated file names specified in file F; If F is - then read names from standard input

--files0-from=F

end each output line with 0 byte rather than newline

-0, --null

skip directories on different file systems

-x, --one-file-system

exclude files that match PATTERN

--exclude=PATTERN

display this help and exit

--help

DevOpsSchool
Typically replies within an hour

DevOpsSchool
Hi there 👋

How can I help you?
×
Chat with Us