du - Summarize usage of file space

Format

du [-a|-s[-krtx] [ pathname ...]

Description

du reports the amount of file space that is used by the files indicated by the given path name. If the path name is a directory, du reports the total amount of file space that is used by all files in that directory and in each subdirectory in its hierarchy. If you do not specify a path name, du assumes the current directory. Files with multiple links are only counted once. On systems supporting symbolic links, only the disk space that is used by the symbolic link is counted.

du measures file space in 512-byte units.

Options

-a
Generates a report for all files in pathname.
-k
Displays file sizes in 1024-byte (1 KB) units.
-r
Reports files that cannot be opened and directories that cannot be read; this is the default.
-s
Does not display file size totals for subdirectories.
-t
Displays the total amount of space used by all path names examined.
-x
Displays file sizes for only those files that are contained on the same device as pathname.

Usage notes

du computes file space in units of 512 bytes. The actual disk space that is used by files and directories might be more, since some systems allocate space in units of some multiple of a sector. On UNIX System V, it is usually two sectors; on UNIX Version 7, it is one sector.

The allocation unit is file system specific.

Localization

du uses the following localization variables:
  • LANG
  • LC_ALL
  • LC_CTYPE
  • LC_MESSAGES
  • NLSPATH

Exit values

0
Successful completion
1
Failure due to any of the following reasons:
  • Incorrect command-line option.
  • Cannot access a directory.
  • Cannot read a directory.
  • Cannot access file information.

Portability

POSIX.2 User Portability Extension, X/Open Portability Guide, UNIX systems.

The -t option is an extension to the POSIX standard.

Related information

df, find, ls