du outputs the amount of disk space used by directories, subdirectories, and ordinary files in blocks of 512 bytes.
Syntax
du[ -a | -s][ -k | -h | -H][ -r][ -x][ file...] |
No option specified If name is a directory, du lists the space occupied by the specified directory and all its subdirectories. The disk space occupied by ordinary files in the specified directory is included in the count, but not listed individually. If name is not a directory, du does not output anything for it.
If file is a directory then du reads the storage space allocated to each of the files in this directory individually. If file is not a directory then du reads the storage space allocated to file. The option -a can be combined with the option -s.
du outputs the occupied storage space, specifying the number of occupied 1024-byte blocks.
du outputs the occupied storage space, converted to kilobytes, megabytes, gigabytes or terabytes (1 KB = 210 bytes, 1 MB = 220 bytes, 1 GB =2 30 bytes, 1 TB = 240
du outputs the occupied storage space, converted to kilobytes, megabytes, gigabytes or terabytes (1 KB = 103 bytes, 1 MB = 106 bytes, 1 GB = 109 bytes, 1 TB = 212
du issues an error message if file is a directory for which you possess no read permission or if it is a file which cannot be opened. The option -r is always set.
du only outputs the total amount of storage space occupied by the section of the file tree or the file. The option -s cannot be combined with the option -a.
When file sizes are calculated, only those files which use the same special file as file are considered.
Name of the file or directory for which disk usage is to be displayed. A file with two or more links is only counted once. A file that has a hole in it (e.g. if only block 1 and block 100 are used) will result in an incorrect block count. If name refers to an ordinary file, du remains silent if invoked without options. file not specified: |
Locale
The following environment variables affect the execution of du: LANG Provide a default value for the internationalization variables that are unset or null. If LANG is unset of null, the corresponding value from the implementation-specific default locale will be used. If any of the internationalization variables contains an invalid setting, the utility will behave as if none of the variables had been defined. LC_ALL If set to a non-empty string value, override the values of all the other internationalization variables. LC_CTYPE 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 and input files), the classification of characters as upper- to lower-case, and the mapping of characters from one case to the other. LC_MESSAGES Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error. NLSPATH Determine the location of message catalogs for the processing of LC_MESSAGES. |
Example 1
List the disk usage, in 512-byte blocks, of all subdirectories of the current directory whose names begin with DIR. The space occupied by ordinary files is included, but not listed individually.
|
Example 2
List the disk usage, in 512-byte blocks, of all subdirectories of the current directory whose names begin with DIR. The disk usage of ordinary files is listed individually in this case because the -a option is used.
|
See also
df |