|Original author(s)||Ken Thompson,|
(AT&T Bell Laboratories)
|Developer(s)||Various open-source and commercial developers|
|Initial release||November 3, 1971|
|Operating system||Unix, Unix-like|
df (abbreviation for disk free) is a standard Unix command used to display the amount of available disk space for file systems on which the invoking user has appropriate read access. df is typically implemented using the statfs or statvfs system calls.
df for Unix-like systems is part of the X/Open Portability Guide since issue 2 of 1987. It was inherited into the first version of POSIX and the Single Unix Specification. It first appeared in Version 1 AT&T Unix.
The version of df bundled in GNU coreutils 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.
The Single UNIX Specification specifications for df are:
df [-k] [-P|-t] [-del] [file...]
Most implementations of df in Unix and Unix-like operating systems include extra options. The BSD and GNU coreutils versions include -h, which lists free space in human readable format displaying units with the appropriate SI prefix (e.g. 10 MB), -i, which lists inode usage, and -l, restricting display to only local filesystems. GNU df includes -T as well, listing filesystem type information, but the GNU df shows the sizes in 1K blocks by default.
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 ls 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 df to df -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:
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:
<space free>, plus any space reserved by the system not normally available to a user.
<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.
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