Df (Unix)
Encyclopedia
df
is a standard UnixUnix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
computer program
Computer program
A computer program is a sequence of instructions written to perform a specified task with a computer. A computer requires programs to function, typically executing the program's instructions in a central processor. The program has an executable form that the computer can use directly to execute...
used to display the amount of available disk space for filesystems on which the invoking user has appropriate read access. df is usually implemented by reading the mtab
Mtab
The mtab file is a system information file, commonly found on Unix-like systems. This file lists all currently mounted filesystems along with their initialization options...
file or using statfs.
df first appeared in Version 1 AT&T UNIX.
Usage
The Single UNIX SpecificationSingle UNIX Specification
The Single UNIX Specification is the collective name of a family of standards for computer operating systems to qualify for the name "Unix"...
specifications for df are:
- -k
- Use 1024-byte units, instead of the default 512-byte units, when writing space figures.
- -P
- Use a standard, portable, output format
- -t
- If XSI compliant, show allocated space as well
- -h
- Display in Kb, Mb, or Gb
- file
- Write the amount of free space of the file system containing the specified file
Most Unix
Unix
Unix is a multitasking, multi-user computer operating system originally developed in 1969 by a group of AT&T employees at Bell Labs, including Ken Thompson, Dennis Ritchie, Brian Kernighan, Douglas McIlroy, and Joe Ossanna...
and Unix-like
Unix-like
A Unix-like operating system is one that behaves in a manner similar to a Unix system, while not necessarily conforming to or being certified to any version of the Single UNIX Specification....
operating systems add extra options. The BSD and GNU coreutils versions include -h, where free space is listed in human readable format, adding units with the appropriate SI prefix
SI prefix
The International System of Units specifies a set of unit prefixes known as SI prefixes or metric prefixes. An SI prefix is a name that precedes a basic unit of measure to indicate a decadic multiple or fraction of the unit. Each prefix has a unique symbol that is prepended to the unit symbol...
(e.g. 10MB), -i, listing inode
Inode
In computing, an inode is a data structure on a traditional Unix-style file system such as UFS. An inode stores all the information about a regular file, directory, or other file system object, except its data and name....
usage, and -l, restricting display to only local filesystems. GNU
GNU
GNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...
df includes -T as well, listing filesystem type information, but the GNU df shows the sizes in 1K blocks by default.
Specification
The Single Unix SpecificationSingle UNIX Specification
The Single UNIX Specification is the collective name of a family of standards for computer operating systems to qualify for the name "Unix"...
(SUS) specifies by default 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 ls
Ls
In computing, ls is a command to list files in Unix and Unix-like operating systems. ls is specified by POSIX and the Single UNIX Specification.- History :An ls utility appeared in the original version of AT&T UNIX...
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 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
Alias (Unix shell)
In computing, alias is a command in various command line interpreters such as Unix shells, 4DOS/4NT and Windows PowerShell, which enables a replacement of a word by another string. It is mainly used for abbreviating a system command, or for adding default arguments to a regularly used command...
df to df -k without breaking many historical scripts relying on the 512-byte units.
The output with -P shall consist of one line of information for each specified file system. These lines shall be formatted as follows:
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:
- 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
Manual pages
- df — manual page from GNUGNUGNU is a Unix-like computer operating system developed by the GNU project, ultimately aiming to be a "complete Unix-compatible software system"...
coreutils - The df Command - by The Linux Information Project (LINFO)