Name

du

Synopsis

    du [options] [directories]

Print disk usage, i.e., the number of blocks used by each named directory and its subdirectories (default is current directory).

Tip

On Solaris and Mac OS X, the default block size is the historic 512 bytes. On GNU/Linux it’s 1024 bytes. Furthermore, the option availability and meanings vary wildly among the different systems, as well as between /usr/bin/du and /usr/xpg4/bin/du on Solaris. The end result is that it’s hard to use du portably in shell scripts, although du -k seems to be a universal least common denominator.

Common Options

-a, --all

Print usage for all files, not just subdirectories.

-h, --human-readable

Print sizes in human-readable format.

-k, --kilobytes

Print information in units of kilobytes.

-L, --dereference

For symbolic links, process the file or directory to which the link refers, not the link itself.

-s, --summarize

Print only the grand total for each named directory.

-x, --one-file-system

Restrict file size evaluations to files on the same filesystem as the command-line file parameter. Not available for Solaris /usr/bin/du.

Solaris Options

-d

Do not cross filesystem boundaries. /usr/bin/du only.

-H

When a symbolic link named on the command line refers to a directory, process the linked-to directory instead of the link itself.

-o

Do not add child-directory statistics to the parent directory’s total. No effect if -s is also used. /usr/bin/du only.

-r

Print a “cannot open” message if a file or directory is inaccessible.

GNU/Linux Options ...

Get Unix in a Nutshell, 4th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.