HOME

TheInfoList



OR:

du, short for ''disk usage'', is a
shell Shell may refer to: Architecture and design * Shell (structure), a thin structure ** Concrete shell, a thin shell of concrete, usually with no interior columns or exterior buttresses Science Biology * Seashell, a hard outer layer of a marine ani ...
command Command may refer to: Computing * Command (computing), a statement in a computer language * command (Unix), a Unix command * COMMAND.COM, the default operating system shell and command-line interpreter for DOS * Command key, a modifier key on A ...
for reporting file system storage use space used for a file or a directory tree. The
Single UNIX Specification The Single UNIX Specification (SUS) is a standard for computer operating systems, compliance with which is required to qualify for using the "UNIX" trademark. The standard specifies programming interfaces for the C language, a command-line shell, ...
(SUS) specifies that by default, du reports the space allocated to each file contained in the
working directory In computing, the working directory of a process is a directory of a hierarchical file system, if any, dynamically associated with the process. It is sometimes called the current working directory (CWD), e.g. the BSD getcwd function, or just c ...
. For a link file, the size of the link file itself is reported, not what it links to. The size of the content of directories is reported. 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 df if files have been deleted but their blocks not yet freed. 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 minfree setting is usually set to about 5% of the total file system size. For more info se
core utils faq


History

The du command first appeared in version 1 of AT&T UNIX. The implementation of du bundled in GNU
coreutils The GNU Core Utilities or coreutils is a collection of GNU software that implements many standard, Unix-based shell commands. The utilities generally provide POSIX compliant interface when the environment variable is set, but otherwise offers ...
was written by Torbjorn Granlund, David MacKenzie, Paul Eggert, and Jim Meyering. The command is also available for
FreeDOS FreeDOS (formerly PD-DOS) is a free software operating system for IBM PC compatible computers. It intends to provide a complete MS-DOS-compatible environment for running Legacy system, legacy software and supporting embedded systems. FreeDOS ca ...
. A similar command is available on
Windows Windows is a Product lining, product line of Proprietary software, proprietary graphical user interface, graphical operating systems developed and marketed by Microsoft. It is grouped into families and subfamilies that cater to particular sec ...
via Sysinternals by Mark Russinovich.


Use

du accepts any number of parameters that each specify a file by
path A path is a route for physical travel – see Trail. Path or PATH may also refer to: Physical paths of different types * Bicycle path * Bridle path, used by people on horseback * Course (navigation), the intended path of a vehicle * Desir ...
to specify the starting scope. If none specified, the working directory is used. SUS mandates the following optional options: * , In addition to the default output, include information for each non-directory entry * , Report the grand total of the storage usage for the specified scope * , The maximum directory tree depth of the scope; deeper directories are ignored; for example, 0 sums the starting scope directory only and 1 sums the starting scope directory and its subdirectories * , Calculate storage usage for link references specified on the command line * , Show sizes as multiples of 1024
byte The byte is a unit of digital information that most commonly consists of eight bits. Historically, the byte was the number of bits used to encode a single character of text in a computer and for this reason it is the smallest addressable un ...
s, not 512-byte * , Calculate storage usage for link references * , Report only the sum of the usage of the starting scope directory; not for subdirectories * , Only traverse files and directories on which the path argument is specified Some implementations support other options. For example, BSD and GNU support a option that selects numbers to be formatted using metric units and
notation In linguistics and semiotics, a notation system is a system of graphics or symbols, Character_(symbol), characters and abbreviated Expression (language), expressions, used (for example) in Artistic disciplines, artistic and scientific disciplines ...
(e.g. 10 MB) instead of bytes.


Examples

Report the storage use for each file and directory tree in
kilobyte The kilobyte is a multiple of the unit byte for Computer data storage, digital information. The International System of Units (SI) defines the prefix ''kilo-, kilo'' as a multiplication factor of 1000 (103); therefore, one kilobyte is 1000&nbs ...
s (): $ du -sk * 152304 directoryOne 1856548 directoryTwo Report the storage use in a more human-readable format (: $ du -sh * 149M directoryOne 1.8G directoryTwo Report the storage use of all subdirectories and files including hidden files within the working directory sorted by file size: $ du -sk . . *, sort -n Report the storage use under in the working directory () with a sum total at the end (), formatted as human-readable (): $ du -d 1 -c -h 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: $ du -d 1 -c -h -x /


See also

* * * *


References


External links

* * {{Core Utilities commands Standard Unix programs Unix SUS2008 utilities Plan 9 commands Inferno (operating system) commands Disk usage analysis software Unix file system-related software