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

NAME

6       du - estimate file space usage
7

SYNOPSIS

9       du [-a | -s][-kx][-H | -L][file ...]
10

DESCRIPTION

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

OPTIONS

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

OPERANDS

65       The following operand shall be supported:
66
67       file   The  pathname  of a file whose size is to be written. If no file
68              is specified, the current directory shall be used.
69
70

STDIN

72       Not used.
73

INPUT FILES

75       None.
76

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

104       Default.
105

STDOUT

107       The  output from du shall consist of the amount of space allocated to a
108       file and the name of the file, in the following format:
109
110
111              "%d %s\n", <size>, <pathname>
112

STDERR

114       The standard error shall be used only for diagnostic messages.
115

OUTPUT FILES

117       None.
118

EXTENDED DESCRIPTION

120       None.
121

EXIT STATUS

123       The following exit values shall be returned:
124
125        0     Successful completion.
126
127       >0     An error occurred.
128
129

CONSEQUENCES OF ERRORS

131       Default.
132
133       The following sections are informative.
134

APPLICATION USAGE

136       None.
137

EXAMPLES

139       None.
140

RATIONALE

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

FUTURE DIRECTIONS

199       None.
200

SEE ALSO

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