Du (Unix)
Encyclopedia
du
is a standard UnixUnix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
program
Computer program
A computer program is a sequence of instructions written to perform a specified task with a computer. A computer requires programs to function, typically executing the program's instructions in a central processor. The program has an executable form that the computer can use directly to execute...
used to estimate file space usage—space used under a particular directory or files
Computer file
A computer file is a block of arbitrary information, or resource for storing information, which is available to a computer program and is usually based on some kind of durable storage. A file is durable in the sense that it remains available for programs to use after the current program has finished...
on a file system
File system
A file system is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it. A file system organizes data in an efficient manner and is tuned to the...
.
Specification
By default, the Single Unix SpecificationSingle UNIX Specification
The Single UNIX Specification is the collective name of a family of standards for computer operating systems to qualify for the name "Unix"...
(SUS) specifies that
du
is to display the file space allocated to each file and directory contained in the current directory. Links will be displayed as the size of the link file, not what is being linked to; the size of the content of directories is displayed, as expected.As
du
reports allocation space and not absolute file space, the amount of space on a file system shown by du
may vary from that shown by dfDf (Unix)df is a standard Unix computer program used to display the amount of available disk space for filesystems on which the invoking user has appropriate read access...
if files have been deleted but their blocks not yet freed. Also the minfree setting that allocates datablocks for the filesystem and the super user processes creates a discrepancy between total blocks and the sum of used and available blocks. The minfree setting is usually set to about 5% of the total filesystem size. For more info see core utils faq.Usage
du
takes a single argument, specifying a pathname for du to work; if it is not specified, the current directory is used. The SUS mandates for du the following options:
- -a, display an entry for each file (and not directory) contained in the current directory
- -H, calculate disk usage for link references specified on the command line
- -k, show sizes as multiples of 1024 byteByteThe byte is a unit of digital information in computing and telecommunications that most commonly consists of eight bits. Historically, a byte was the number of bits used to encode a single character of text in a computer and for this reason it is the basic addressable element in many computer...
s, not 512-byte - -L, calculate disk usage for link references anywhere
- -s, report only the sum of the usage in the current directory, not for each file
- -x, only traverse files and directories on the device on which the pathname argument is specified.
Other Unix and Unix-like operating systems may add extra options. For example, BSD and GNU
du
specify a -h option, displaying disk usage in a format easier to read by the user, adding units with the appropriate SI prefixSI prefix
The International System of Units specifies a set of unit prefixes known as SI prefixes or metric prefixes. An SI prefix is a name that precedes a basic unit of measure to indicate a decadic multiple or fraction of the unit. Each prefix has a unique symbol that is prepended to the unit symbol...
(e.g. 10 MB
Megabyte
The megabyte is a multiple of the unit byte for digital information storage or transmission with two different values depending on context: bytes generally for computer memory; and one million bytes generally for computer storage. The IEEE Standards Board has decided that "Mega will mean 1 000...
).
Examples
Sum of directories in kilobyteKilobyte
The kilobyte is a multiple of the unit byte for digital information. Although the prefix kilo- means 1000, the term kilobyte and symbol KB have historically been used to refer to either 1024 bytes or 1000 bytes, dependent upon context, in the fields of computer science and information...
s:
Sum of directories in human-readable
Human-readable
A human-readable medium or human-readable format is a representation of data or information that can be naturally read by humans.In computing, human-readable data is often encoded as ASCII or Unicode text, rather than presented in a binary representation...
format (Byte, Kilobyte, Megabyte, Gigabyte, Terabyte and Petabyte):
disk usage of all subdirectories and files including hidden files within the current directory (sorted by filesize) :
disk usage of all subdirectories and files including hidden files within the current directory (sorted by reverse filesize) :
The weight of directories:
Manual pages
- du — manual page from GNUGNUGNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...
coreutils - du — manual page from OpenBSDOpenBSDOpenBSD is a Unix-like computer operating system descended from Berkeley Software Distribution , a Unix derivative developed at the University of California, Berkeley. It was forked from NetBSD by project leader Theo de Raadt in late 1995...
- du — manual page from Dragonflybsd
Other
- Disk space-related utilities at Freshmeat.net