<code>du</code> is a shell command for reporting the file system storage allocated to files and directory trees. With no command-line arguments, it reports the space allocated to the working directory and to each directory tree that it contains, recursively. Space allocated to files is reported if files are specified for inclusion. For a symbolic link file, the size of the link file is reported, not what it links to.
Although du is short for disk usage, the command is not limited to disk storage. It was developed during the long period of time when disk-based storage was the ubiquitous mass storage technology.
differs from <code>df</code> in that reports size information of file system items whereas reports statistics about the storage media as a whole. can report more detailed information, but can take longer to complete when processing many files. Also, since a storage media may have allocated space that is not associated with an accessible file (i.e. file was deleted but space not freed), might report more allocated space than if it were used to calculate the space of all files of a media. Also, the minfree setting that allocates data blocks for the file system and the super user processes creates a discrepancy between total blocks and the sum of used and available blocks.
The <code>du</code> command first appeared in version 1 of AT&T UNIX. It is specified by the Single UNIX Specification (SUS). The implementation in GNU coreutils was written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim Meyering. The command is also available for FreeDOS. A similar command is available for Windows in Sysinternals by Mark Russinovich.
<code>du</code> accepts any number of parameters that each specify a file by path to specify the starting scope. If none specified, the working directory is used. SUS mandates the following optional options:
Some implementations support other options. For example, BSD and GNU support a option that selects numbers to be formatted using metric units and notation (e.g. 10 MB) instead of bytes.
Report the storage use for each file and directory tree in kilobytes ():
Report the storage use in a more human-readable format (:
Report the storage use of all subdirectories and files including hidden files within the working directory sorted by file size:
Report the storage use under in the working directory () with a sum total at the end (), formatted as human-readable ():
For the GNU implementation, is used instead of .
Report the storage use under the root directory (, trailing ) with a sum total at the end (), formatted as human-readable () without traversing into other file systems (). Useful when /var, /tmp or other directories are on separate storage from the root directory: