DU(1)                      POSIX Programmer's Manual                     DU(1)



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


NNAAMMEE
       du -- estimate file space usage

SSYYNNOOPPSSIISS
       du [[-a|-s]] [[-kx]] [[-H|-L]] [[_f_i_l_e...]]

DDEESSCCRRIIPPTTIIOONN
       By default, the _d_u utility shall write to standard output the size of
       the file space allocated to, and the size of the file space allocated
       to each subdirectory of, the file hierarchy rooted in each of the
       specified files. By default, when a symbolic link is encountered on the
       command line or in the file hierarchy, _d_u shall count the size of the
       symbolic link (rather than the file referenced by the link), and shall
       not follow the link to another portion of the file hierarchy. The size
       of the file space allocated to a file of type directory shall be
       defined as the sum total of space allocated to all files in the file
       hierarchy rooted in the directory plus the space allocated to the
       directory itself.

       When _d_u cannot _s_t_a_t() files or _s_t_a_t() or read directories, it shall
       report an error condition and the final exit status is affected. Files
       with multiple links shall be counted and written for only one entry.
       The directory entry that is selected in the report is unspecified. By
       default, file sizes shall be written in 512-byte units, rounded up to
       the next 512-byte unit.

OOPPTTIIOONNSS
       The _d_u utility shall conform to the Base Definitions volume of
       POSIX.1-2008, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s.

       The following options shall be supported:

       --aa        In addition to the default output, report the size of each
                 file not of type directory in the file hierarchy rooted in
                 the specified file.  Regardless of the presence of the --aa
                 option, non-directories given as _f_i_l_e operands shall always
                 be listed.

       --HH        If a symbolic link is specified on the command line, _d_u shall
                 count the size of the file or file hierarchy referenced by
                 the link.

       --kk        Write the files sizes in units of 1024 bytes, rather than the
                 default 512-byte units.

       --LL        If a symbolic link is specified on the command line or
                 encountered during the traversal of a file hierarchy, _d_u
                 shall count the size of the file or file hierarchy referenced
                 by the link.

       --ss        Instead of the default output, report only the total sum for
                 each of the specified files.

       --xx        When evaluating file sizes, evaluate only those files that
                 have the same device as the file specified by the _f_i_l_e
                 operand.

       Specifying more than one of the mutually-exclusive options --HH and --LL
       shall not be considered an error. The last option specified shall
       determine the behavior of the utility.

OOPPEERRAANNDDSS
       The following operand shall be supported:

       _f_i_l_e      The pathname of a file whose size is to be written. If no
                 _f_i_l_e is specified, the current directory shall be used.

SSTTDDIINN
       Not used.

IINNPPUUTT FFIILLEESS
       None.

EENNVVIIRROONNMMEENNTT VVAARRIIAABBLLEESS
       The following environment variables shall affect the execution of _d_u:

       _L_A_N_G      Provide a default value for the internationalization
                 variables that are unset or null. (See the Base Definitions
                 volume of POSIX.1-2008, _S_e_c_t_i_o_n _8_._2, _I_n_t_e_r_n_a_t_i_o_n_a_l_i_z_a_t_i_o_n
                 _V_a_r_i_a_b_l_e_s for the precedence of internationalization
                 variables used to determine the values of locale categories.)

       _L_C___A_L_L    If set to a non-empty string value, override the values of
                 all the other internationalization variables.

       _L_C___C_T_Y_P_E  Determine the locale for the interpretation of sequences of
                 bytes of text data as characters (for example, single-byte as
                 opposed to multi-byte characters in arguments).

       _L_C___M_E_S_S_A_G_E_S
                 Determine the locale that should be used to affect the format
                 and contents of diagnostic messages written to standard
                 error.

       _N_L_S_P_A_T_H   Determine the location of message catalogs for the processing
                 of _L_C___M_E_S_S_A_G_E_S.

AASSYYNNCCHHRROONNOOUUSS EEVVEENNTTSS
       Default.

SSTTDDOOUUTT
       The output from _d_u shall consist of the amount of space allocated to a
       file and the name of the file, in the following format:

           ""%%dd %%ss\\nn"",, <<_s_i_z_e>, <_p_a_t_h_n_a_m_e>

SSTTDDEERRRR
       The standard error shall be used only for diagnostic messages.

OOUUTTPPUUTT FFIILLEESS
       None.

EEXXTTEENNDDEEDD DDEESSCCRRIIPPTTIIOONN
       None.

EEXXIITT SSTTAATTUUSS
       The following exit values shall be returned:

        0    Successful completion.

       >0    An error occurred.

CCOONNSSEEQQUUEENNCCEESS OOFF EERRRROORRSS
       Default.

       _T_h_e _f_o_l_l_o_w_i_n_g _s_e_c_t_i_o_n_s _a_r_e _i_n_f_o_r_m_a_t_i_v_e_.

AAPPPPLLIICCAATTIIOONN UUSSAAGGEE
       None.

EEXXAAMMPPLLEESS
       None.

RRAATTIIOONNAALLEE
       The use of 512-byte units is historical practice and maintains
       compatibility with _l_s and other utilities in this volume of
       POSIX.1-2008. This does not mandate that the file system itself be
       based on 512-byte blocks. The --kk option was added as a compromise
       measure. It was agreed by the standard developers that 512 bytes was
       the best default unit because of its complete historical consistency on
       System V (_v_e_r_s_u_s the mixed 512/1024-byte usage on BSD systems), and
       that a --kk option to switch to 1024-byte units was a good compromise.
       Users who prefer the 1024-byte quantity can easily alias _d_u to _d_u --kk
       without breaking the many historical scripts relying on the 512-byte
       units.

       The --bb option was added to an early proposal to provide a resolution to
       the situation where System V and BSD systems give figures for file
       sizes in _b_l_o_c_k_s, which is an implementation-defined concept. (In common
       usage, the block size is 512 bytes for System V and 1024 bytes for BSD
       systems.)  However, --bb was later deleted, since the default was
       eventually decided as 512-byte units.

       Historical file systems provided no way to obtain exact figures for the
       space allocation given to files. There are two known areas of
       inaccuracies in historical file systems: cases of _i_n_d_i_r_e_c_t _b_l_o_c_k_s being
       used by the file system or _s_p_a_r_s_e files yielding incorrectly high
       values. An indirect block is space used by the file system in the
       storage of the file, but that need not be counted in the space
       allocated to the file. A _s_p_a_r_s_e file is one in which an _l_s_e_e_k() call
       has been made to a position beyond the end of the file and data has
       subsequently been written at that point. A file system need not
       allocate all the intervening zero-filled blocks to such a file. It is
       up to the implementation to define exactly how accurate its methods
       are.

       The --aa and --ss options were mutually-exclusive in the original version
       of _d_u.  The POSIX Shell and Utilities description is implied by the
       language in the SVID where --ss is described as causing ``only the grand
       total'' to be reported. Some systems may produce output for --ssaa, but a
       Strictly Conforming POSIX Shell and Utilities Application cannot use
       that combination.

       The --aa and --ss options were adopted from the SVID except that the System
       V behavior of not listing non-directories explicitly given as operands,
       unless the --aa option is specified, was considered a bug; the BSD-based
       behavior (report for all operands) is mandated. The default behavior of
       _d_u in the SVID with regard to reporting the failure to read files (it
       produces no messages) was considered counter-intuitive, and thus it was
       specified that the POSIX Shell and Utilities default behavior shall be
       to produce such messages. These messages can be turned off with shell
       redirection to achieve the System V behavior.

       The --xx option is historical practice on recent BSD systems. It has been
       adopted by this volume of POSIX.1-2008 because there was no other
       historical method of limiting the _d_u search to a single file hierarchy.
       This limitation of the search is necessary to make it possible to
       obtain file space usage information about a file system on which other
       file systems are mounted, without having to resort to a lengthy _f_i_n_d
       and _a_w_k script.

FFUUTTUURREE DDIIRREECCTTIIOONNSS
       None.

SSEEEE AALLSSOO
       _l_s

       The Base Definitions volume of POSIX.1-2008, _C_h_a_p_t_e_r _8, _E_n_v_i_r_o_n_m_e_n_t
       _V_a_r_i_a_b_l_e_s, _S_e_c_t_i_o_n _1_2_._2, _U_t_i_l_i_t_y _S_y_n_t_a_x _G_u_i_d_e_l_i_n_e_s

       The System Interfaces volume of POSIX.1-2008, _f_s_t_a_t_a_t()

CCOOPPYYRRIIGGHHTT
       Portions of this text are reprinted and reproduced in electronic form
       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
       -- Portable Operating System Interface (POSIX), The Open Group Base
       Specifications Issue 7, Copyright (C) 2013 by the Institute of
       Electrical and Electronics Engineers, Inc and The Open Group.  (This is
       POSIX.1-2008 with the 2013 Technical Corrigendum 1 applied.) In the
       event of any discrepancy between this version and the original IEEE and
       The Open Group Standard, the original IEEE and The Open Group Standard
       is the referee document. The original Standard can be obtained online
       at http://www.unix.org/online.html .

       Any typographical or formatting errors that appear in this page are
       most likely to have been introduced during the conversion of the source
       files to man page format. To report such errors, see
       https://www.kernel.org/doc/man-pages/reporting_bugs.html .



IEEE/The Open Group                  2013                                DU(1)
