DF(1POSIX)
πΎ DF(1POSIX) πΎ
okay bestie, welcome to the POSIX Programmer's Manual π this one's df β the girl who tells you how much free disk space you've got left, no cap.
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. Heads up though: the Linux implementation of this interface may differ (so consult the corresponding Linux manual page for the deets on Linux behavior), or the interface may not be implemented on Linux at all. just a lil vibe check before we dive in π«Ά
β¨ NAME β¨
df β report free disk space. that's it, that's the whole job π
β¨ SYNOPSIS β¨
df [-k] [-P|-t] [file...]
β¨ DESCRIPTION β¨
So df shall write the amount of available space and file slots for file systems where the invoking user has appropriate read access. read access is the entry fee bestie, no access no info π
File systems get specified by the file operands. When none are specified? It writes info for all the file systems. all of them. the whole roster. π
The format of the default output from df is unspecified, but here's the tea: all space figures are reported in 512-byte units, unless the -k option is specified.
This output shall contain at least:
- the file system names
- the amount of available space on each of these file systems
- and, if no options other than
-tare specified, the number of free file slots, or inodes, available
and when -t is specified, the output shall contain the total allocated space as well. more data, more slay β¨
β¨ OPTIONS β¨
The df utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines. house rules, we follow them π
The following options shall be supported:
-kβ Use 1024-byte units, instead of the default 512-byte units, when writing space figures. the upgrade we deserve π-Pβ Produce output in the format described in the STDOUT section. portable queen behavior π-tβ Include total allocated-space figures in the output. totals, because we love a summary π
β¨ OPERANDS β¨
The following operand shall be supported:
- file β A pathname of a file within the hierarchy of the desired file system.
okay so file has LAYERS, let's unpack:
If a file other than a FIFO, a regular file, a directory, or a special file representing the device containing the file system (for example, /dev/dsk/0s1) is specified, the results are unspecified. unspecified = we don't know what happens, and honestly? don't test it π
If the file operand names a file other than a special file containing a file system, df shall write the amount of free space in the file system containing the specified file operand.
Otherwise, df shall write the amount of free space in that file system.
tl;dr β point at a file, get the stats for the filesystem it lives in π¦
β¨ STDIN β¨
Not used. she doesn't read, she only speaks π
β¨ INPUT FILES β¨
None. nothing to see here β¨
β¨ ENVIRONMENT VARIABLES β¨
The following environment variables shall affect the execution of df:
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. the ultimate override, main character energy π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 and informative messages written to standard output.NLSPATHβ Determine the location of message catalogs for the processing ofLC_MESSAGES.
β¨ ASYNCHRONOUS EVENTS β¨
Default. nothing extra, keep it moving π
β¨ STDOUT β¨
okay this is the part where it gets β¨specificβ¨ so lock in bestie π₯
When both the -k and -P options are specified, the following header line shall be written (in the POSIX locale):
"Filesystem 1024-blocks Used Available Capacity Mounted on\n"
When the -P option is specified without the -k option, the following header line shall be written (in the POSIX locale):
"Filesystem 512-blocks Used Available Capacity Mounted on\n"
The implementation may adjust the spacing of the header line and the individual data lines so that the information is presented in orderly columns. aesthetic alignment, we love to see it π
The remaining output with -P shall consist of one line of information for each specified file system. These lines shall be formatted as follows:
"%s %d %d %d %d%% %s\n", <file system name>, <total space>,
<space used>, <space free>, <percentage used>,
<file system root>
In the following list, all quantities expressed in 512-byte units (1024-byte when -k is specified) shall be rounded up to the next higher unit. The fields are:
<file system name>β The name of the file system, in an implementation-defined format.<total space>β The total size of the file system in 512-byte units. The exact meaning of this figure is implementation-defined, but should include<space used>,<space free>, plus any space reserved by the system not normally available to a user.<space used>β The total amount of space allocated to existing files in the file system, in 512-byte units.<space free>β The total amount of space available within the file system for the creation of new files by unprivileged users, in 512-byte units. When this figure is less than or equal to zero, it shall not be possible to create any new files on the file system without first deleting others, unless the process has appropriate privileges. The figure written may be less than zero. yes, negative. it's giving chaos but it's real π<percentage used>β The percentage of the normally available space that is currently allocated to all files on the file system. This shall be calculated using the fraction:
<space used>/( <space used>+ <space free>)
expressed as a percentage. This percentage may be greater than 100 if <space free> is less than zero. The percentage value shall be expressed as a positive integer, with any fractional result causing it to be rounded to the next highest integer. round UP always, she's generous π
<file system root>β The directory below which the file system hierarchy appears.
The output format is unspecified when-tis used. so don't come for her about the-tlayout okay π
β¨ STDERR β¨
The standard error shall be used only for diagnostic messages. only the drama lives here π
β¨ OUTPUT FILES β¨
None. she writes to stdout, not to files, periodt β¨
β¨ EXTENDED DESCRIPTION β¨
None. nothing more to add bestie, moving on π
β¨ EXIT STATUS β¨
The following exit values shall be returned:
0β Successful completion. we ate π>0β An error occurred. oof π
β¨ CONSEQUENCES OF ERRORS β¨
Default.
The following sections are informative. aka the bonus content, the behind-the-scenes π
β¨ APPLICATION USAGE β¨
On most systems, the ``name of the file system, in an implementation-defined format'' is the special file on which the file system is mounted. iykyk π
On large file systems, the calculation specified for percentage used can create huge rounding errors. yeah, math gets a lil wobbly up there, ngl π¦
β¨ EXAMPLES β¨
- The following example writes portable information about the
/usrfile system:
df -P /usr
- Assuming that
/usr/srcis part of the/usrfile system, the following produces the same output as the previous example:
df -P /usr/src
same file system, same result β she's consistent like that π
β¨ RATIONALE β¨
okay this is the lore drop, sit down for this one π
The behavior of df with the -P option is the default action of the 4.2 BSD df utility. The uppercase -P was selected to avoid collision with a known industry extension using -p. capital P for the win, lowercase p was taken π
Historical df implementations vary considerably in their default output. It was therefore necessary to describe the default output in a loose manner to accommodate all known historical implementations and to add a portable option (-P) to provide information in a portable format.
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 more logical 1024-byte quantity can easily alias df to df -k without breaking many historical scripts relying on the 512-byte units. compromise core, honestly π
It was suggested that df and the various related utilities be modified to access a BLOCKSIZE environment variable to achieve consistency and user acceptance. Since this is not historical practice on any system, it is left as a possible area for system extensions and will be re-evaluated in a future version if it is widely implemented. so like... maybe someday? not today tho π¦
β¨ FUTURE DIRECTIONS β¨
None. no plans, she's thriving as-is π
β¨ SEE ALSO β¨
find- The Base Definitions volume of POSIX.1β2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
β¨ 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 . go read the source material bestie, it's free π
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 . blame the conversion, not the content π
and that's the whole page bestie!! π this was brought to you by IEEE/The Open Group, 2017 β the iconic duo behind DF(1POSIX) πβ¨ go touch some disk space, 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