1DU(1P)                     POSIX Programmer's Manual                    DU(1P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       du - estimate file space usage
13

SYNOPSIS

15       du [-a | -s][-kx][-H | -L][file ...]
16

DESCRIPTION

18       By default, the du utility shall write to standard output the  size  of
19       the  file  space allocated to, and the size of the file space allocated
20       to each subdirectory of, the file hierarchy rooted in each of the spec‐
21       ified  files.  By  default,  when a symbolic link is encountered on the
22       command line or in the file hierarchy, du shall count the size  of  the
23       symbolic  link (rather than the file referenced by the link), and shall
24       not follow the link to another portion of the file hierarchy. The  size
25       of  the  file  space  allocated  to  a  file of type directory shall be
26       defined as the sum total of space allocated to all files  in  the  file
27       hierarchy  rooted  in  the  directory  plus  the space allocated to the
28       directory itself.
29
30       When du cannot stat() files or stat() or  read  directories,  it  shall
31       report  an error condition and the final exit status is affected. Files
32       with multiple links shall be counted and written for  only  one  entry.
33       The  directory  entry that is selected in the report is unspecified. By
34       default, file sizes shall be written in 512-byte units, rounded  up  to
35       the next 512-byte unit.
36

OPTIONS

38       The  du  utility  shall  conform  to  the  Base  Definitions  volume of
39       IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
40
41       The following options shall be supported:
42
43       -a     In addition to the default output, report the size of each  file
44              not of type directory in the file hierarchy rooted in the speci‐
45              fied file. Regardless of the presence of  the  -a  option,  non-
46              directories given as file operands shall always be listed.
47
48       -H     If  a  symbolic  link is specified on the command line, du shall
49              count the size of the file or file hierarchy referenced  by  the
50              link.
51
52       -k     Write  the  files  sizes in units of 1024 bytes, rather than the
53              default 512-byte units.
54
55       -L     If a symbolic link is specified on the command line  or  encoun‐
56              tered  during  the traversal of a file hierarchy, du shall count
57              the size of the file or file hierarchy referenced by the link.
58
59       -s     Instead of the default output, report only  the  total  sum  for
60              each of the specified files.
61
62       -x     When  evaluating file sizes, evaluate only those files that have
63              the same device as the file specified by the file operand.
64
65
66       Specifying more than one of the mutually-exclusive options  -H  and  -L
67       shall  not  be  considered  an  error.  The last option specified shall
68       determine the behavior of the utility.
69

OPERANDS

71       The following operand shall be supported:
72
73       file   The pathname of a file whose size is to be written. If  no  file
74              is specified, the current directory shall be used.
75
76

STDIN

78       Not used.
79

INPUT FILES

81       None.
82

ENVIRONMENT VARIABLES

84       The following environment variables shall affect the execution of du:
85
86       LANG   Provide  a  default value for the internationalization variables
87              that are unset or null. (See  the  Base  Definitions  volume  of
88              IEEE Std 1003.1-2001,  Section  8.2,  Internationalization Vari‐
89              ables for the precedence of internationalization variables  used
90              to determine the values of locale categories.)
91
92       LC_ALL If  set  to a non-empty string value, override the values of all
93              the other internationalization variables.
94
95       LC_CTYPE
96              Determine the locale for  the  interpretation  of  sequences  of
97              bytes  of  text  data as characters (for example, single-byte as
98              opposed to multi-byte characters in arguments).
99
100       LC_MESSAGES
101              Determine the locale that should be used to  affect  the  format
102              and contents of diagnostic messages written to standard error.
103
104       NLSPATH
105              Determine the location of message catalogs for the processing of
106              LC_MESSAGES .
107
108

ASYNCHRONOUS EVENTS

110       Default.
111

STDOUT

113       The output from du shall consist of the amount of space allocated to  a
114       file and the name of the file, in the following format:
115
116
117              "%d %s\n", <size>, <pathname>
118

STDERR

120       The standard error shall be used only for diagnostic messages.
121

OUTPUT FILES

123       None.
124

EXTENDED DESCRIPTION

126       None.
127

EXIT STATUS

129       The following exit values shall be returned:
130
131        0     Successful completion.
132
133       >0     An error occurred.
134
135

CONSEQUENCES OF ERRORS

137       Default.
138
139       The following sections are informative.
140

APPLICATION USAGE

142       None.
143

EXAMPLES

145       None.
146

RATIONALE

148       The use of 512-byte units is historical practice and maintains compati‐
149       bility   with   ls   and   other   utilities   in   this   volume    of
150       IEEE Std 1003.1-2001. This does not mandate that the file system itself
151       be based on 512-byte blocks. The -k option was added  as  a  compromise
152       measure.   It  was agreed by the standard developers that 512 bytes was
153       the best default unit because of its complete historical consistency on
154       System  V  (versus  the  mixed 512/1024-byte usage on BSD systems), and
155       that a -k option to switch to 1024-byte units was  a  good  compromise.
156       Users  who  prefer  the 1024-byte quantity can easily alias du to du -k
157       without breaking the many historical scripts relying  on  the  512-byte
158       units.
159
160       The -b option was added to an early proposal to provide a resolution to
161       the situation where System V and BSD  systems  give  figures  for  file
162       sizes in blocks, which is an implementation-defined concept. (In common
163       usage, the block size is 512 bytes for System V and 1024 bytes for  BSD
164       systems.)  However, -b was later deleted, since the default was eventu‐
165       ally decided as 512-byte units.
166
167       Historical file systems provided no way to obtain exact figures for the
168       space allocation given to files. There are two known areas of inaccura‐
169       cies in historical file systems: cases of indirect blocks being used by
170       the  file  system  or sparse files yielding incorrectly high values. An
171       indirect block is space used by the file system in the storage  of  the
172       file,  but that need not be counted in the space allocated to the file.
173       A sparse file is one in which an lseek() call has been made to a  posi‐
174       tion  beyond the end of the file and data has subsequently been written
175       at that point. A file system need  not  allocate  all  the  intervening
176       zero-filled  blocks  to  such a file. It is up to the implementation to
177       define exactly how accurate its methods are.
178
179       The -a and -s options were mutually-exclusive in the  original  version
180       of du. The POSIX Shell and Utilities description is implied by the lan‐
181       guage in the SVID where -s is described  as  causing  "only  the  grand
182       total"  to be reported.  Some systems may produce output for -sa, but a
183       Strictly Conforming POSIX Shell and Utilities  Application  cannot  use
184       that combination.
185
186       The -a and -s options were adopted from the SVID except that the System
187       V behavior of not listing non-directories explicitly given as operands,
188       unless  the -a option is specified, was considered a bug; the BSD-based
189       behavior (report for all operands) is mandated. The default behavior of
190       du  in  the SVID with regard to reporting the failure to read files (it
191       produces no messages) was considered counter-intuitive, and thus it was
192       specified  that the POSIX Shell and Utilities default behavior shall be
193       to produce such messages. These messages can be turned off  with  shell
194       redirection to achieve the System V behavior.
195
196       The  -x  option  is  historical practice on recent BSD systems.  It has
197       been adopted by this volume of IEEE Std 1003.1-2001 because  there  was
198       no  other  historical method of limiting the du search to a single file
199       hierarchy. This limitation of the search is necessary to make it possi‐
200       ble to obtain file space usage information about a file system on which
201       other file systems are mounted, without having to resort to  a  lengthy
202       find and awk script.
203

FUTURE DIRECTIONS

205       None.
206

SEE ALSO

208       ls, the System Interfaces volume of IEEE Std 1003.1-2001, stat()
209
211       Portions  of  this text are reprinted and reproduced in electronic form
212       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
213       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
214       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
215       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
216       event of any discrepancy between this version and the original IEEE and
217       The  Open Group Standard, the original IEEE and The Open Group Standard
218       is the referee document. The original Standard can be  obtained  online
219       at http://www.opengroup.org/unix/online.html .
220
221
222
223IEEE/The Open Group                  2003                               DU(1P)
Impressum