Original author(s) | Ken Thompson, Dennis Ritchie (AT&T Bell Laboratories) |
---|---|
Developer(s) | Various open-source and commercial developers |
Initial release | 3 November 1971 |
Operating system | Unix, Unix-like |
Platform | Cross-platform |
Type | Command |
License | coreutils: GPLv3+ |
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. [1] It first appeared in Version 1 AT&T Unix. [2]
The version of df bundled in GNU coreutils was written by Torbjorn Granlund, David MacKenzie, and Paul Eggert. [3] 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. [4]
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 [5] ), -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:
<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>
<total space>
<space used>
, <space free>
, plus any space reserved by the system not normally available to a user.<space used>
<space free>
<percentage used>
<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>
Example outputs of the df command:
$ df Filesystem 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-i Filesystem 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-h Filesystem 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
In computing, ls
is a command to list computer files and directories in Unix and Unix-like operating systems. It is specified by POSIX and the Single UNIX Specification.
The Filesystem Hierarchy Standard (FHS) is a reference describing the conventions used for the layout of Unix-like systems. It has been made popular by its use in Linux distributions, but it is used by other Unix-like systems as well. It is maintained by the Linux Foundation. The latest version is 3.0, released on 3 June 2015.
The ln
command is a standard Unix command utility used to create a hard link or a symbolic link (symlink) to an existing file or directory. The use of a hard link allows multiple filenames to be associated with the same file since a hard link points to the inode of a given file, the data of which is stored on disk. On the other hand, symbolic links are special files that refer to other files by name.
tmpfs is a temporary file storage paradigm implemented in many Unix-like operating systems. It is intended to appear as a mounted file system, but data is stored in volatile memory instead of a persistent storage device.
dd is a command-line utility for Unix, Plan 9, Inferno, and Unix-like operating systems and beyond, the primary purpose of which is to convert and copy files. On Unix, device drivers for hardware and special device files appear in the file system just like normal files; dd can also read and/or write from/to these files, provided that function is implemented in their respective driver. As a result, dd can be used for tasks such as backing up the boot sector of a hard drive, and obtaining a fixed amount of random data. The dd program can also perform conversions on the data as it is copied, including byte order swapping and conversion to and from the ASCII and EBCDIC text encodings.
join
is a command in Unix and Unix-like operating systems that merges the lines of two sorted text files based on the presence of a common field. It is similar to the join operator used in relational databases but operating on text files.
wc
is a command in Unix, Plan 9, Inferno, and Unix-like operating systems. The program reads either standard input or a list of computer files and generates one or more of the following statistics: newline count, word count, and byte count. If a list of files is provided, both individual file and total statistics follow.
fstab is a system file commonly found in the directory /etc
on Unix and Unix-like computer systems. In Linux, it is part of the util-linux package. The fstab file typically lists all available disk partitions and other types of file systems and data sources that may not necessarily be disk-based, and indicates how they are to be initialized or otherwise integrated into the larger file system structure.
cksum
is a command in Unix and Unix-like operating systems that generates a checksum value for a file or stream of data. The cksum command reads each file given in its arguments, or standard input if no arguments are provided, and outputs the file's 32-bit cyclic redundancy check (CRC) checksum and byte count. The CRC output by cksum is different from the CRC-32 used in zip, PNG and zlib.
du
is a standard Unix program used to estimate file space usage—space used under a particular directory or files on a file system. A Windows commandline version of this program is part of Sysinternals suite by Mark Russinovich.
In computing, cmp
is a command-line utility on Unix and Unix-like operating systems that compares two files of any type and writes the results to the standard output. By default, cmp
is silent if the files are the same; if they differ, the byte and line number at which the first difference occurred is reported. The command is also available in the OS-9 shell.
mv
is a Unix command that moves one or more files or directories from one place to another. If both filenames are on the same filesystem, this results in a simple file rename; otherwise the file content is copied to the new location and the old file is removed. Using mv
requires the user to have write permission for the directories the file will move between. This is because mv
changes the content of both directories involved in the move. When using the mv
command on files located on the same filesystem, the file's timestamp is not updated.
Filesystem in Userspace (FUSE) is a software interface for Unix and Unix-like computer operating systems that lets non-privileged users create their own file systems without editing kernel code. This is achieved by running file system code in user space while the FUSE module provides only a bridge to the actual kernel interfaces.
rm
is a basic command on Unix and Unix-like operating systems used to remove objects such as computer files, directories and symbolic links from file systems and also special files such as device nodes, pipes and sockets, similar to the del
command in MS-DOS, OS/2, and Microsoft Windows. The command is also available in the EFI shell.
NILFS or NILFS2 is a log-structured file system implementation for the Linux kernel. It was developed by Nippon Telegraph and Telephone Corporation (NTT) CyberSpace Laboratories and a community from all over the world. NILFS was released under the terms of the GNU General Public License (GPL).
The following tables compare general and technical information for a number of file systems.
sum is a legacy utility available on some Unix and Unix-like operating systems. This utility outputs a 16-bit checksum of each argument file, as well as the number of blocks they take on disk. Two different checksum algorithms are in use. POSIX abandoned sum
in favor of cksum.
The csplit
command in Unix and Unix-like operating systems is a utility that is used to split a file into two or more smaller files determined by context lines.
cat
is a standard Unix utility that reads files sequentially, writing them to standard output. The name is derived from its function to (con)catenate files . It has been ported to a number of operating systems.
mktemp is a command available in many Unix-like operating systems that creates a temporary file or directory. Originally released in 1997 as part of OpenBSD 2.1, a separate implementation exists as a part of GNU Coreutils.