📄 df.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta name="generator" content="HTML Tidy, see www.w3.org"><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><link type="text/css" rel="stylesheet" href="style.css"><!-- Generated by The Open Group's rhtm tool v1.2.1 --><!-- Copyright (c) 2001-2003 The Open Group, All Rights Reserved --><title>df</title></head><body bgcolor="white"><script type="text/javascript" language="JavaScript" src="../jscript/codes.js"></script><basefont size="3"> <a name="df"></a> <a name="tag_04_36"></a><!-- df --> <!--header start--><center><font size="2">The Open Group Base Specifications Issue 6<br>IEEE Std 1003.1, 2003 Edition<br>Copyright © 2001-2003 The IEEE and The Open Group, All Rights reserved.</font></center><!--header end--><hr size="2" noshade><h4><a name="tag_04_36_01"></a>NAME</h4><blockquote>df - report free disk space</blockquote><h4><a name="tag_04_36_02"></a>SYNOPSIS</h4><blockquote class="synopsis"><div class="box"><code><tt><sup>[<a href="javascript:open_code('UP XSI')">UP XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> df</tt> <b>[</b><tt>-k</tt><b>][</b><tt>-P|-t</tt><b>][</b><i>file</i><tt>...</tt><b>]</b><tt><imgsrc="../images/opt-end.gif" alt="[Option End]" border="0"></tt></code></div></blockquote><h4><a name="tag_04_36_03"></a>DESCRIPTION</h4><blockquote><p>The <i>df</i> utility shall write the amount of available space <sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <imgsrc="../images/opt-start.gif" alt="[Option Start]" border="0"> and file slots <img src="../images/opt-end.gif" alt="[Option End]" border="0"> for file systems on which the invoking user has appropriate read access. File systems shall be specifiedby the <i>file</i> operands; when none are specified, information shall be written for all file systems. The format of the defaultoutput from <i>df</i> is unspecified, but all space figures are reported in 512-byte units, unless the <b>-k</b> option isspecified. This output shall contain at least the file system names, amount of available space on each of these file systems,<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> and the number of free file slots, or <i>inodes</i>, available; when <b>-t</b> is specified, the output shall contain thetotal allocated space as well. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_04_36_04"></a>OPTIONS</h4><blockquote><p>The <i>df</i> utility shall conform to the Base Definitions volume of IEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap12.html#tag_12_02">Section 12.2, Utility Syntax Guidelines</a>.</p><p>The following options shall be supported:</p><dl compact><dt><b>-k</b></dt><dd>Use 1024-byte units, instead of the default 512-byte units, when writing space figures.</dd><dt><b>-P</b></dt><dd>Produce output in the format described in the STDOUT section.</dd><dt><b>-t</b></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Include total allocated-space figures in the output. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_36_05"></a>OPERANDS</h4><blockquote><p>The following operand shall be supported:</p><dl compact><dt><i>file</i></dt><dd>A pathname of a file within the hierarchy of the desired file system. If a file other than a FIFO, a regular file, a directory,<sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0"> or a special file representing the device containing the file system (for example, <b>/dev/dsk/0s1</b>) <img src="../images/opt-end.gif" alt="[Option End]" border="0"> is specified, the results are unspecified. Otherwise, <i>df</i> shall writethe amount of free space in the file system containing the specified <i>file</i> operand.</dd></dl></blockquote><h4><a name="tag_04_36_06"></a>STDIN</h4><blockquote><p>Not used.</p></blockquote><h4><a name="tag_04_36_07"></a>INPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_36_08"></a>ENVIRONMENT VARIABLES</h4><blockquote><p>The following environment variables shall affect the execution of <i>df</i>:</p><dl compact><dt><i>LANG</i></dt><dd>Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume ofIEEE Std 1003.1-2001, <a href="../basedefs/xbd_chap08.html#tag_08_02">Section 8.2, Internationalization Variables</a> forthe precedence of internationalization variables used to determine the values of locale categories.)</dd><dt><i>LC_ALL</i></dt><dd>If set to a non-empty string value, override the values of all the other internationalization variables.</dd><dt><i>LC_CTYPE</i></dt><dd>Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte asopposed to multi-byte characters in arguments).</dd><dt><i>LC_MESSAGES</i></dt><dd>Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error andinformative messages written to standard output.</dd><dt><i>NLSPATH</i></dt><dd><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">Determine the location of message catalogs for the processing of <i>LC_MESSAGES .</i> <img src="../images/opt-end.gif" alt="[Option End]" border="0"></dd></dl></blockquote><h4><a name="tag_04_36_09"></a>ASYNCHRONOUS EVENTS</h4><blockquote><p>Default.</p></blockquote><h4><a name="tag_04_36_10"></a>STDOUT</h4><blockquote><p>When both the <b>-k</b> and <b>-P</b> options are specified, the following header line shall be written (in the POSIXlocale):</p><pre><tt>"Filesystem 1024-blocks Used Available Capacity Mounted on\n"</tt></pre><p>When the <b>-P</b> option is specified without the <b>-k</b> option, the following header line shall be written (in the POSIXlocale):</p><pre><tt>"Filesystem 512-blocks Used Available Capacity Mounted on\n"</tt></pre><p>The implementation may adjust the spacing of the header line and the individual data lines so that the information is presentedin orderly columns.</p><p>The remaining output with <b>-P</b> shall consist of one line of information for each specified file system. These lines shallbe formatted as follows:</p><pre><tt>"%s %d %d %d %d%% %s\n", <</tt><i>file system name</i><tt>>, <</tt><i>total space</i><tt>>, <</tt><i>space used</i><tt>>, <</tt><i>space free</i><tt>>, <</tt><i>percentage used</i><tt>>, <</tt><i>file system root</i><tt>></tt></pre><p>In the following list, all quantities expressed in 512-byte units (1024-byte when <b>-k</b> is specified) shall be rounded up tothe next higher unit. The fields are:</p><dl compact><dt><<i>file system name</i>></dt><dd><br>The name of the file system, in an implementation-defined format.</dd><dt><<i>total space</i>></dt><dd>The total size of the file system in 512-byte units. The exact meaning of this figure is implementation-defined, but shouldinclude <<i>space used</i>>, <<i>space free</i>>, plus any space reserved by the system not normallyavailable to a user.</dd><dt><<i>space used</i>></dt><dd>The total amount of space allocated to existing files in the file system, in 512-byte units.</dd><dt><<i>space free</i>></dt><dd>The total amount of space available within the file system for the creation of new files by unprivileged users, in 512-byteunits. When this figure is less than or equal to zero, it shall not be possible to create any new files on the file system withoutfirst deleting others, unless the process has appropriate privileges. The figure written may be less than zero.</dd><dt><<i>percentage used</i>></dt><dd><br>The percentage of the normally available space that is currently allocated to all files on the file system. This shall becalculated using the fraction: <pre><tt><</tt><i>space used</i><tt>>/( <</tt><i>space used</i><tt>>+ <</tt><i>space free</i><tt>>)</tt></pre><p>expressed as a percentage. This percentage may be greater than 100 if <<i>space free</i>> is less than zero. Thepercentage value shall be expressed as a positive integer, with any fractional result causing it to be rounded to the next highestinteger.</p></dd><dt><<i>file system root</i>></dt><dd><br>The directory below which the file system hierarchy appears.</dd></dl><p><sup>[<a href="javascript:open_code('XSI')">XSI</a>]</sup> <img src="../images/opt-start.gif" alt="[Option Start]" border="0">The output format is unspecified when <b>-t</b> is used. <img src="../images/opt-end.gif" alt="[Option End]" border="0"></p></blockquote><h4><a name="tag_04_36_11"></a>STDERR</h4><blockquote><p>The standard error shall be used only for diagnostic messages.</p></blockquote><h4><a name="tag_04_36_12"></a>OUTPUT FILES</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_36_13"></a>EXTENDED DESCRIPTION</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_36_14"></a>EXIT STATUS</h4><blockquote><p>The following exit values shall be returned:</p><dl compact><dt> 0</dt><dd>Successful completion.</dd><dt>>0</dt><dd>An error occurred.</dd></dl></blockquote><h4><a name="tag_04_36_15"></a>CONSEQUENCES OF ERRORS</h4><blockquote><p>Default.</p></blockquote><hr><div class="box"><em>The following sections are informative.</em></div><h4><a name="tag_04_36_16"></a>APPLICATION USAGE</h4><blockquote><p>On most systems, the "name of the file system, in an implementation-defined format" is the special file on which the filesystem is mounted.</p><p>On large file systems, the calculation specified for percentage used can create huge rounding errors.</p></blockquote><h4><a name="tag_04_36_17"></a>EXAMPLES</h4><blockquote><ol><li><p>The following example writes portable information about the <b>/usr</b> file system:</p><pre><tt>df -P /usr</tt></pre></li><li><p>Assuming that <b>/usr/src</b> is part of the <b>/usr</b> file system, the following produces the same output as the previousexample:</p><pre><tt>df -P /usr/src</tt></pre></li></ol></blockquote><h4><a name="tag_04_36_18"></a>RATIONALE</h4><blockquote><p>The behavior of <i>df</i> with the <b>-P</b> option is the default action of the 4.2 BSD <i>df</i> utility. The uppercase<b>-P</b> was selected to avoid collision with a known industry extension using <b>-p</b>.</p><p>Historical <i>df</i> implementations vary considerably in their default output. It was therefore necessary to describe thedefault output in a loose manner to accommodate all known historical implementations and to add a portable option ( <b>-P</b>) toprovide information in a portable format.</p><p>The use of 512-byte units is historical practice and maintains compatibility with <a href="../utilities/ls.html"><i>ls</i></a>and other utilities in this volume of IEEE Std 1003.1-2001. This does not mandate that the file system itself be based on512-byte blocks. The <b>-k</b> option was added as a compromise measure. It was agreed by the standard developers that 512 byteswas the best default unit because of its complete historical consistency on System V (<i>versus</i> the mixed 512/1024-byte usageon BSD systems), and that a <b>-k</b> option to switch to 1024-byte units was a good compromise. Users who prefer the more logical1024-byte quantity can easily alias <i>df</i> to <i>df</i> <b>-k</b> without breaking many historical scripts relying on the512-byte units.</p><p>It was suggested that <i>df</i> and the various related utilities be modified to access a <i>BLOCKSIZE</i> environment variableto achieve consistency and user acceptance. Since this is not historical practice on any system, it is left as a possible area forsystem extensions and will be re-evaluated in a future version if it is widely implemented.</p></blockquote><h4><a name="tag_04_36_19"></a>FUTURE DIRECTIONS</h4><blockquote><p>None.</p></blockquote><h4><a name="tag_04_36_20"></a>SEE ALSO</h4><blockquote><p><a href="find.html"><i>find</i></a></p></blockquote><h4><a name="tag_04_36_21"></a>CHANGE HISTORY</h4><blockquote><p>First released in Issue 2.</p></blockquote><h4><a name="tag_04_36_22"></a>Issue 6</h4><blockquote><p>This utility is marked as part of the User Portability Utilities option.</p></blockquote><div class="box"><em>End of informative text.</em></div><hr><hr size="2" noshade><center><font size="2"><!--footer start-->UNIX ® is a registered Trademark of The Open Group.<br>POSIX ® is a registered Trademark of The IEEE.<br>[ <a href="../mindex.html">Main Index</a> | <a href="../basedefs/contents.html">XBD</a> | <a href="../utilities/contents.html">XCU</a> | <a href="../functions/contents.html">XSH</a> | <a href="../xrat/contents.html">XRAT</a>]</font></center><!--footer end--><hr size="2" noshade></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -