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
11

NAME

13       du — estimate file space usage
14

SYNOPSIS

16       du [−a|−s] [−kx] [−H|−L] [file...]
17

DESCRIPTION

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

OPTIONS

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

OPERANDS

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

STDIN

80       Not used.
81

INPUT FILES

83       None.
84

ENVIRONMENT VARIABLES

86       The following environment variables shall affect the execution of du:
87
88       LANG      Provide a default value for  the  internationalization  vari‐
89                 ables  that are unset or null. (See the Base Definitions vol‐
90                 ume of POSIX.1‐2008, Section 8.2, Internationalization  Vari‐
91                 ables  for  the  precedence of internationalization variables
92                 used to determine the values of locale categories.)
93
94       LC_ALL    If set to a non-empty string value, override  the  values  of
95                 all the other internationalization variables.
96
97       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
98                 bytes of text data as characters (for example, single-byte as
99                 opposed to multi-byte characters in arguments).
100
101       LC_MESSAGES
102                 Determine the locale that should be used to affect the format
103                 and contents  of  diagnostic  messages  written  to  standard
104                 error.
105
106       NLSPATH   Determine the location of message catalogs for the processing
107                 of LC_MESSAGES.
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           "%d %s\n", <size>, <pathname>
117

STDERR

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

OUTPUT FILES

122       None.
123

EXTENDED DESCRIPTION

125       None.
126

EXIT STATUS

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

CONSEQUENCES OF ERRORS

135       Default.
136
137       The following sections are informative.
138

APPLICATION USAGE

140       None.
141

EXAMPLES

143       None.
144

RATIONALE

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

FUTURE DIRECTIONS

202       None.
203

SEE ALSO

205       ls
206
207       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
208       Variables, Section 12.2, Utility Syntax Guidelines
209
210       The System Interfaces volume of POSIX.1‐2008, fstatat()
211
213       Portions  of  this text are reprinted and reproduced in electronic form
214       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
215       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
216       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
217       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
218       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
219       event of any discrepancy between this version and the original IEEE and
220       The Open Group Standard, the original IEEE and The Open Group  Standard
221       is  the  referee document. The original Standard can be obtained online
222       at http://www.unix.org/online.html .
223
224       Any typographical or formatting errors that appear  in  this  page  are
225       most likely to have been introduced during the conversion of the source
226       files to man page format. To report such errors,  see  https://www.ker
227       nel.org/doc/man-pages/reporting_bugs.html .
228
229
230
231IEEE/The Open Group                  2013                               DU(1P)
Impressum