manpagez: man pages & more
info coreutils
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

14.2 du: Estimate file space usage

du reports the amount of disk space used by the specified files and for each subdirectory (of directory arguments). Synopsis:

du [option]… [file]…

With no arguments, du reports the disk space for the current directory. Normally the disk space is printed in units of 1024 bytes, but this can be overridden (see section Block size). Non-integer quantities are rounded up to the next higher unit.

The program accepts the following options. Also see Common options.


Show counts for all files, not just directories.


Print apparent sizes, rather than disk usage. The apparent size of a file is the number of bytes reported by wc -c on regular files, or more generally, ls -l --block-size=1 or stat --format=%s. For example, a file containing the word ‘zoo’ with no newline would, of course, have an apparent size of 3. Such a small file may require anywhere from 0 to 16 KiB or more of disk space, depending on the type and configuration of the file system on which the file resides. However, a sparse file created with this command:

dd bs=1 seek=2GiB if=/dev/null of=big

has an apparent size of 2 GiB, yet on most modern systems, it actually uses almost no disk space.


Equivalent to --apparent-size --block-size=1.

-B size

Scale sizes by size before printing them (see section Block size). For example, ‘-BG’ prints sizes in units of 1,073,741,824 bytes.


Print a grand total of all arguments after all arguments have been processed. This can be used to find out the total disk usage of a given set of files or directories.


Dereference symbolic links that are command line arguments. Does not affect other symbolic links. This is helpful for finding out the disk usage of directories, such as ‘/usr/tmp’, which are often symbolic links.


Rather than processing files named on the command line, process those named in file FILE; each name is terminated by a null byte. This is useful with the ‘--total’ (‘-c’) option when the list of file names is so long that it may exceed a command line length limitation. In such cases, running du via xargs is undesirable because it splits the list into pieces and makes du print a total for each sublist rather than for the entire list. One way to produce a list of null-byte-terminated file names is with GNU find, using its ‘-print0’ predicate. Do not specify any FILE on the command line when using this option.


Append a size letter to each size, such as ‘M’ for mebibytes. Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes. This option is equivalent to ‘--block-size=human-readable’. Use the ‘--si’ option if you prefer powers of 1000.


Currently, ‘-H’ is the same as ‘--si’, except that ‘-H’ evokes a warning. This option will be changed to be equivalent to ‘--dereference-args’ (‘-D’).


Print sizes in 1024-byte blocks, overriding the default block size (see section Block size). This option is equivalent to ‘--block-size=1K’.


Count the size of all files, even if they have appeared already (as a hard link).


Dereference symbolic links (show the disk space used by the file or directory that the link points to instead of the space used by the link).


Print sizes in 1,048,576-byte blocks, overriding the default block size (see section Block size). This option is equivalent to ‘--block-size=1M’.


For each symbolic links encountered by du, consider the disk space used by the symbolic link.


Show the total for each directory (and file if –all) that is at most MAX_DEPTH levels down from the root of the hierarchy. The root is at level 0, so du --max-depth=0 is equivalent to du -s.


Output a null byte at the end of each line, rather than a newline. This option enables other programs to parse the output of du even when that output would contain file names with embedded newlines.


Append an SI-style abbreviation to each size, such as ‘M’ for megabytes. Powers of 1000 are used, not 1024; ‘M’ stands for 1,000,000 bytes. This option is equivalent to ‘--block-size=si’. Use the ‘-h’ or ‘--human-readable’ option if you prefer powers of 1024.


Display only a total for each argument.


Report the size of each directory separately, not including the sizes of subdirectories.


Show time of the most recent modification of any file in the directory, or any of its subdirectories.


Show the most recent status change time (the ‘ctime’ in the inode) of any file in the directory, instead of the modification time.


Show the most recent access time (the ‘atime’ in the inode) of any file in the directory, instead of the modification time.


List timestamps in style style. This option has an effect only if the ‘--time’ option is also specified. The style should be one of the following:


List timestamps using format, where format is interpreted like the format argument of date (see section date: Print or set system date and time). For example, ‘--time-style="+%Y-%m-%d %H:%M:%S"’ causes du to list timestamps like ‘2002-03-30 23:45:56’. As with date, format's interpretation is affected by the LC_TIME locale category.


List timestamps in full using ISO 8601 date, time, and time zone format with nanosecond precision, e.g., ‘2002-03-30 23:45:56.477817180 -0700’. This style is equivalent to ‘+%Y-%m-%d %H:%M:%S.%N %z’.


List ISO 8601 date and time in minutes, e.g., ‘2002-03-30 23:45’. These timestamps are shorter than ‘full-iso’ timestamps, and are usually good enough for everyday work. This style is equivalent to ‘+%Y-%m-%d %H:%M’.


List ISO 8601 dates for timestamps, e.g., ‘2002-03-30’. This style is equivalent to ‘+%Y-%m-%d’.

You can specify the default value of the ‘--time-style’ option with the environment variable TIME_STYLE; if TIME_STYLE is not set the default style is ‘long-iso’. For compatibility with ls, if TIME_STYLE begins with ‘+’ and contains a newline, the newline and any later characters are ignored; if TIME_STYLE begins with ‘posix-’ the ‘posix-’ is ignored; and if TIME_STYLE is ‘locale’ it is ignored.


Skip directories that are on different file systems from the one that the argument being processed is on.


When recursing, skip subdirectories or files matching PATTERN. For example, du --exclude='*.o' excludes files whose names end in ‘.o’.


Like ‘--exclude’, except take the patterns to exclude from FILE, one per line. If FILE is ‘-’, take the patterns from standard input.

On BSD systems, du reports sizes that are half the correct values for files that are NFS-mounted from HP-UX systems. On HP-UX systems, it reports sizes that are twice the correct values for files that are NFS-mounted from BSD systems. This is due to a flaw in HP-UX; it also affects the HP-UX du program.

An exit status of zero indicates success, and a nonzero value indicates failure.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© 2000-2017
Individual documents may contain additional copyright information.