Movatterモバイル変換


[0]ホーム

URL:


Jump to content
WikipediaThe Free Encyclopedia
Search

df (Unix)

From Wikipedia, the free encyclopedia
Standard Unix command
df
Example usage ofdf
Original author(s)Ken Thompson,
Dennis Ritchie
(AT&T Bell Laboratories)
Developer(s)Variousopen-source andcommercial developers
Initial release3 November 1971; 53 years ago (1971-11-03)
Operating systemUnix,Unix-like
PlatformCross-platform
TypeCommand
Licensecoreutils:GPLv3+

df (abbreviation fordiskfree) is a standardUnix command used to display the amount of available disk space forfile systems on which the invokinguser has appropriate read access.df is typically implemented using thestatfs or statvfssystem calls.

History

[edit]

df forUnix-like systems is part of theX/Open Portability Guide since issue 2 of 1987. It was inherited into the first version ofPOSIX and theSingle Unix Specification.[1] It first appeared inVersion 1 AT&T Unix.[2]

The version ofdf bundled inGNUcoreutils was written by Torbjorn Granlund, David MacKenzie, and Paul Eggert.[3] The command is available as a separate package forMicrosoft Windows as part of theUnxUtils collection ofnativeWin32ports of common GNU Unix-like utilities.[4]

Usage

[edit]

The Single UNIX Specification specifications fordf are:

df [-k] [-P|-t] [-del] [file...]
-k
Use 1024-byte units, instead of the default 512-byte units, when writing space figures.
-P
Use a standard, portable, output format
file
Write the amount of free space of the file system containing the specified file

Most implementations ofdf inUnix andUnix-like operating systems include extra options. TheBSD andGNU coreutils versions include-h, which lists free space inhuman readable format displaying units with the appropriateSI prefix (e.g. 10MB[5]),-i, which listsinode usage, and-l, restricting display to only local filesystems.GNUdf includes-T as well, listing filesystem type information, but the GNUdf shows the sizes in 1K blocks by default.

Specification

[edit]

The Single Unix Specification (SUS) specifies by original space is reported in blocks of 512 bytes, and that at a minimum, the file system names and the amount of free space.

The use of 512-byte units is historical practice and maintains compatibility withls and other utilities. 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 onSystem V (versus the mixed 512/1024-byte usage onBSD 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 easilyaliasdf todf -k without breaking many historical scripts relying on the 512-byte units.

The output with-P consists of one line of information for each specified file system. These lines are formatted as follows:

<fs name><total space><space used><space free><percentage used><fs root>

In the following list, all quantities expressed in 512-byte units (1024-byte when -k is specified) will be rounded up to the next higher unit. The fields are:

<fs 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 byunprivileged 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.
<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.
<fs root>
The directory below which the file system hierarchy appear

Example

[edit]

Example outputs of the df command:

$dfFilesystem      1K-blocks      Used  Available Use% Mounted onudev             48764976         0   48764976   0% /devtmpfs             9757068    173100    9583968   2% /run/dev/sda2      1824504008 723009800 1008791744  42% /tmpfs            48785328         0   48785328   0% /dev/shmtmpfs                5120         0       5120   0% /run/locktmpfs            48785328         0   48785328   0% /sys/fs/cgroup/dev/sda1          523248      3672     519576   1% /boot/efi$df-iFilesystem        Inodes   IUsed     IFree IUse% Mounted onudev            12191244     500  12190744    1% /devtmpfs           12196332     702  12195630    1% /run/dev/sda2      115859456 2583820 113275636    3% /tmpfs           12196332       1  12196331    1% /dev/shmtmpfs           12196332       5  12196327    1% /run/locktmpfs           12196332      16  12196316    1% /sys/fs/cgroup/dev/sda1              0       0         0     - /boot/efi$df-hFilesystem      Size  Used Avail Use% Mounted onudev             47G     0   47G   0% /devtmpfs           9.4G  170M  9.2G   2% /run/dev/sda2       1.7T  690G  963G  42% /tmpfs            47G     0   47G   0% /dev/shmtmpfs           5.0M     0  5.0M   0% /run/locktmpfs            47G     0   47G   0% /sys/fs/cgroup/dev/sda1       511M  3.6M  508M   1% /boot/efi

See also

[edit]

References

[edit]
  1. ^df – Shell and Utilities Reference,The Single UNIX Specification, Version 4 fromThe Open Group
  2. ^df(1) – FreeBSD General CommandsManual
  3. ^df(1) – Linux General CommandsManual
  4. ^"Native Win32 ports of some GNU utilities".unxutils.sourceforge.net.
  5. ^1 MB = one million bytes

External links

[edit]
The WikibookGuide to Unix has a page on the topic of:Commands

Manual pages

[edit]
File system
Processes
User environment
Text processing
Shell builtins
Searching
Documentation
Software development
Miscellaneous
File system
Text utilities
Shell utilities
Retrieved from "https://en.wikipedia.org/w/index.php?title=Df_(Unix)&oldid=1255848122"
Categories:
Hidden categories:

[8]ページ先頭

©2009-2025 Movatter.jp