(abbreviation for ''disk free'') is a standard
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
command used to display the amount of available disk space for
file system
In computing, file system or filesystem (often abbreviated to fs) is a method and data structure that the operating system uses to control how data is stored and retrieved. Without a file system, data placed in a storage medium would be one lar ...
s on which the invoking
user has appropriate read access. is typically implemented using the
statfs or statvfs
system call
In computing, a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the operating system on which it is executed. This may include hardware-related services (for example, acc ...
s.
History
for
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
systems is part of the
X/Open X/Open group (also known as the Open Group for Unix Systems and incorporated in 1987 as X/Open Company, Ltd.) was a consortium founded by several European UNIX systems manufacturers in 1984 to identify and promote open standards in the field of in ...
Portability Guide since issue 2 of 1987. It was inherited into the first version of
POSIX
The Portable Operating System Interface (POSIX) is a family of standards specified by the IEEE Computer Society for maintaining compatibility between operating systems. POSIX defines both the system- and user-level application programming inte ...
and the
Single Unix Specification. It first appeared in
Version 1 AT&T Unix.
The version of bundled in
GNU coreutils
The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.
In September 2002, the ''GNU coreutils'' were c ...
was written by Torbjorn Granlund, David MacKenzie, and Paul Eggert. The command is available as a separate package for
Microsoft Windows as part of the
UnxUtils collection of
native Win32 ports of common GNU Unix-like utilities.
Usage
The Single UNIX Specification specifications for are:
df
k -t del ile...
;
:Use 1024-byte units, instead of the default 512-byte units, when writing space figures.
;
:Use a standard, portable, output format
;
:Display in more easily human readable units such as KB, MB, GB or TB.
;
:Write the amount of free space of the file system containing the specified file
Most implementations of in
Unix
Unix (; trademarked as UNIX) is a family of multitasking, multiuser computer operating systems that derive from the original AT&T Unix, whose development started in 1969 at the Bell Labs research center by Ken Thompson, Dennis Ritchie, a ...
and
Unix-like
A Unix-like (sometimes referred to as UN*X or *nix) operating system is one that behaves in a manner similar to a Unix system, although not necessarily conforming to or being certified to any version of the Single UNIX Specification. A Unix-li ...
operating systems include extra options. The
BSD and
GNU coreutils versions include , which lists free space in
human readable format displaying units with the appropriate
SI prefix
The International System of Units, known by the international abbreviation SI in all languages and sometimes pleonastically as the SI system, is the modern form of the metric system and the world's most widely used system of measurement. ...
(e.g. 10
MB[1 MB = one million bytes]), , which lists
inode
The inode (index node) is a data structure in a Unix-style file system that describes a file-system object such as a file or a directory. Each inode stores the attributes and disk block locations of the object's data. File-system object attribu ...
usage, and , restricting display to only local filesystems.
GNU includes as well, listing filesystem type information, but the GNU shows the sizes in 1K blocks by default.
Specification
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 with and other utilities. This does not mandate that the file system itself be based on 512-byte blocks. The 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
Unix System V (pronounced: "System Five") is one of the first commercial versions of the Unix operating system. It was originally developed by AT&T and first released in 1983. Four major versions of System V were released, numbered 1, 2, 3, an ...
(versus the mixed 512/1024-byte usage on
BSD systems), and that a option to switch to 1024-byte units was a good compromise. Users who prefer the more logical 1024-byte quantity can easily to without breaking many historical scripts relying on the 512-byte units.
The output with consists of one line of information for each specified file system. These lines are formatted as follows:
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:
;
:The name of the file system, in an implementation-defined format.
;
:The total size of the file system in 512-byte units. The exact meaning of this figure is implementation-defined, but should include , , plus any space reserved by the system not normally available to a user.
;
:The total amount of space allocated to existing files in the file system, in 512-byte units.
;
: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.
;
: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:
::
:expressed as a percentage. This percentage may be greater than 100 if 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.
;
:The directory below which the file system hierarchy appear
Example
Example outputs of the df command:
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
udev 48764976 0 48764976 0% /dev
tmpfs 9757068 173100 9583968 2% /run
/dev/sda2 1824504008 723009800 1008791744 42% /
tmpfs 48785328 0 48785328 0% /dev/shm
tmpfs 5120 0 5120 0% /run/lock
tmpfs 48785328 0 48785328 0% /sys/fs/cgroup
/dev/sda1 523248 3672 519576 1% /boot/efi
$ df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
udev 12191244 500 12190744 1% /dev
tmpfs 12196332 702 12195630 1% /run
/dev/sda2 115859456 2583820 113275636 3% /
tmpfs 12196332 1 12196331 1% /dev/shm
tmpfs 12196332 5 12196327 1% /run/lock
tmpfs 12196332 16 12196316 1% /sys/fs/cgroup
/dev/sda1 0 0 0 - /boot/efi
$ df -h
Filesystem Size Used Avail Use% Mounted on
udev 47G 0 47G 0% /dev
tmpfs 9.4G 170M 9.2G 2% /run
/dev/sda2 1.7T 690G 963G 42% /
tmpfs 47G 0 47G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 47G 0 47G 0% /sys/fs/cgroup
/dev/sda1 511M 3.6M 508M 1% /boot/efi
See also
*
List of Unix commands
This is a list of Unix commands as specified by IEEE Std 1003.1-2008, which is part of the Single UNIX Specification (SUS). These commands can be found on Unix operating systems and most Unix-like operating systems.
List
See also
* List of G ...
*
du (Unix)
References
External links
*
Manual pages
df— manual page from
GNU coreutils
The GNU Core Utilities or coreutils is a package of GNU software containing implementations for many of the basic tools, such as cat, ls, and rm, which are used on Unix-like operating systems.
In September 2002, the ''GNU coreutils'' were c ...
*
The df Command– by The Linux Information Project (LINFO)
{{Core Utilities commands
Standard Unix programs
Unix SUS2008 utilities