DU(1POSIX)
π PROLOG π
okay so bestie, real talk before we even start: this manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (so like, consult the corresponding Linux manual page for details of Linux behavior, fr), or the interface may not even be implemented on Linux. iykyk. π
β¨ NAME β¨
du β estimate file space usage π
this is du(1POSIX), and she is THAT girl for figuring out how much disk space your stuff is eating.
π¦ SYNOPSIS π¦
du [-a|-s] [-kx] [-H|-L] [file...]
πΈ DESCRIPTION πΈ
okay so by default, du writes 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. like, it walks the whole tree and tells you the damage. π
By default, when a symbolic link is encountered on the command line or in the file hierarchy, du 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. so it's giving "i see you but i'm not chasing you".
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. periodt.
When du cannot stat() files or stat() or read directories, it shall report an error condition and the final exit status is affected. bestie, that error is coming for your exit code, no cap.
A file that occurs multiple times under one file operand and that has a link count greater than 1 shall be counted and written for only one entry. It is implementation-defined whether a file that has a link count no greater than 1 is counted and written just once, or is counted and written for each occurrence. It is implementation-defined whether a file that occurs under one file operand is counted for other file operands. 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. yes, 512. not 1000. not 1024. we'll get into why later and honestly it's a whole thing. π
π OPTIONS π
The du utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines. β¨
The following options shall be supported:
-aβ 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. The-aoption shall not affect whether non-directories given as file operands are listed. lowkey the "show me the individual files too" button π-Hβ If a symbolic link is specified on the command line,dushall count the size of the file or file hierarchy referenced by the link. so like, only the links you typed get followed.-kβ Write the files sizes in units of 1024 bytes, rather than the default 512-byte units. the people's champion option, honestly π-Lβ If a symbolic link is specified on the command line or encountered during the traversal of a file hierarchy,dushall count the size of the file or file hierarchy referenced by the link. this one follows links EVERYWHERE. main character energy, no chill.-sβ Instead of the default output, report only the total sum for each of the specified files. just the grand total, nothing else, we're keeping it cute and brief π-xβ When evaluating file sizes, evaluate only those files that have the same device as the file specified by the file operand. stay in your lane, stay on your filesystem, literally.
bestie listen: specifying more than one of the mutually-exclusive options-Hand-Lshall not be considered an error. The last option specified shall determine the behavior of the utility. so whichever one you say last? she's the one in charge. the audacity, the drama, the rules. π
π§ OPERANDS π§
The following operand shall be supported:
fileβ The pathname of a file whose size is to be written. If nofileis specified, the current directory shall be used. so if you just typeduwith nothing, she's measuring wherever you're standing rn. πΈ
β STDIN β
Not used. she doesn't want your input, she's busy. π
π INPUT FILES π
None. nope. nada.
π· ENVIRONMENT VARIABLES π·
The following environment variables shall affect the execution of du:
LANGβ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ If set to a non-empty string value, override the values of all the other internationalization variables. she overrides EVERYONE. the queen bee πLC_CTYPEβ 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).LC_MESSAGESβ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.NLSPATHβ Determine the location of message catalogs for the processing ofLC_MESSAGES.
π ASYNCHRONOUS EVENTS π
Default. nothing special, she's unbothered. π
π STDOUT π
The output from du shall consist of the amount of space allocated to a file and the name of the file, in the following format:
"%d %s\n", <size>, <pathname>
so like, a number, a space, a pathname, and a newline. she's simple, she's clean, she ATE. β¨
π STDERR π
The standard error shall be used only for diagnostic messages. that's the group chat where the problems get reported.
π¦ OUTPUT FILES π¦
None.
π EXTENDED DESCRIPTION π
None. we love a section that knows when to sit down and be quiet.
π₯ EXIT STATUS π₯
The following exit values shall be returned:
0β Successful completion. we love a happy ending π>0β An error occurred. π
πΈ CONSEQUENCES OF ERRORS πΈ
Default.
The following sections are informative.
π§ APPLICATION USAGE π§
None. (informative section, she's just vibing)
π EXAMPLES π
None. (also just vibing, no examples today bestie)
π RATIONALE π
okay THIS is the lore section, get comfy. π«Ά
The use of 512-byte units is historical practice and maintains compatibility with ls and other utilities in this volume of POSIX.1β2017. This does not mandate that the file system itself be based on 512-byte blocks. The -k 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 (versus the mixed 512/1024-byte usage on BSD systems), and that a -k option to switch to 1024-byte units was a good compromise. Users who prefer the 1024-byte quantity can easily alias du to du -k without breaking the many historical scripts relying on the 512-byte units. so like, the committee said "okay we'll give you a flag, just don't touch the default". iconic compromise behavior. π
The -b 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 blocks, 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, -b was later deleted, since the default was eventually decided as 512-byte units. rip -b, you tried. π
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 indirect blocks being used by the file system or sparse 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 sparse file is one in which an lseek() 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. so like, the numbers are VIBES sometimes. bestie, they're estimates. the name of the game is estimate file space usage. π«
The -a and -s options were mutually-exclusive in the original version of du. The POSIX Shell and Utilities description is implied by the language in the SVID where -s is described as causing "only the grand total" to be reported. Some systems may produce output for -sa, but a Strictly Conforming POSIX Shell and Utilities Application cannot use that combination. so -sa? not for you, strictly conforming app. π
The -a and -s options were adopted from the SVID except that the System V behavior of not listing non-directories explicitly given as operands, unless the -a option is specified, was considered a bug; the BSD-based behavior (report for all operands) is mandated. The default behavior of du 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. so basically: POSIX said "silently failing is a bug, we're telling you about it," and if you want the old silent treatment you can just redirect it away yourself. π
The -x option is historical practice on recent BSD systems. It has been adopted by this volume of POSIX.1β2017 because there was no other historical method of limiting the du 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 find and awk script. no more find + awk combo for you bestie, just say -x. β¨
π¦ FUTURE DIRECTIONS π¦
A future version of this standard may require that a file that occurs multiple times shall be counted and written for only one entry, even if the occurrences are under different file operands. foreshadowing?? π
π«Ά SEE ALSO π«Ά
ls
The Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
The System Interfaces volume of POSIX.1β2017, fstatat()
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. 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.opengroup.org/unix/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 . π
and that's the whole page bestie!! this one came from the fine people at IEEE/The Open Group, dated 2017, and it's DU(1POSIX) in the POSIX Programmer's Manual. go check your disk usage, mwah πβ¨πΈ
π¦ where this page comes from
- debian bookworm: manpages-posix 2017a-2 Β· Other
- debian trixie: manpages-posix 2017a-2 Β· Other
- ubuntu jammy: manpages-posix 2017a-2 Β· Other
- ubuntu noble: manpages-posix 2017a-2 Β· Other
- ubuntu resolute: manpages-posix 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms