du - estimate file space usage
du [-a| -s][-kx][-r][file ...]
By default, the du utility writes to standard output the size of the file space allocated to, and the size of the file space allocated to each subdirectory of, the file hierarchy rooted in each of the specified files. The size of the file space allocated to a file of type directory is defined as the sum total of space allocated to all files in the file hierarchy rooted in the directory plus the space allocated to the directory itself.
When du cannot stat() files or stat() or read directories, it will report an error condition and the final exit status will be affected. Files with multiple links will be counted and written for only one entry. The directory entry that is selected in the report is unspecified. By default, file sizes are written in 512-byte units, rounded up to the next 512-byte unit.
The du utility supports the XBD specification, Utility Syntax Guidelines .
The following options are supported:
- In addition to the default output, report the size of each file not of type directory in the file hierarchy rooted in the specified file. Regardless of the presence of the -a option, non-directories given as file operands will always be listed.
- Write the files sizes in units of 1024 bytes, rather than the default 512-byte units.
- Generate messages about directories that cannot be read, files that cannot be opened, and so on. This is the default case.
- Instead of the default output, report only the total sum for each of the specified files.
- When evaluating file sizes, evaluate only those files that have the same device as the file specified by the file operand.
The following operand is supported:
- The pathname of a file whose size is to be written. If no file is specified, the current directory is used.
The following environment variables affect the execution of du:
- Provide a default value for the internationalisation variables that are unset or null. If LANG is unset or null, the corresponding value from the implementation-dependent default locale will be used. If any of the internationalisation variables contains an invalid setting, the utility will behave as if none of the variables had been defined.
- If set to a non-empty string value, override the values of all the other internationalisation variables.
- Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single- as opposed to multi-byte characters in arguments).
- Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.
- Determine the location of message catalogues for the processing of LC_MESSAGES .
The output from du consists of the amount of the space allocated to a file and the name of the file, in the following format:
"%d %s\n", <size>, <pathname>
Used only for diagnostic messages.
The following exit values are returned:
- Successful completion.
- An error occurred.