How much space do I have left on my hard drive? Is there enough free disk space to download a large file or install a new application?
On Linux and Unix operating systems, you can use the df
command to get a detailed report on the system’s disk space usage.
Using the df Command
The general syntax for the df
command is as follows:
df [OPTIONS]... FILESYSTEM...
When used without any argument, the df
command will display information about all mounted file systems :
df
Filesystem 1K-blocks Used Available Use% Mounted on
dev 8172848 0 8172848 0% /dev
run 8218640 1696 8216944 1% /run
/dev/nvme0n1p3 222284728 183057872 27865672 87% /
tmpfs 8218640 150256 8068384 2% /dev/shm
tmpfs 8218640 0 8218640 0% /sys/fs/cgroup
tmpfs 8218640 24 8218616 1% /tmp
/dev/nvme0n1p1 523248 107912 415336 21% /boot
/dev/sda1 480588496 172832632 283320260 38% /data
tmpfs 1643728 40 1643688 1% /run/user/1000
Each line includes the following columns:
- “Filesystem” – The name of the filesystem.
- “1K-blocks” – The size of the filesystem in 1K blocks.
- “Used” – The used space in 1K blocks.
- “Available” – The available space in 1K blocks.
- “Use%” – The percentage of used space.
- “Mounted on” the directory on which the filesystem is mounted.
To display information only for a specific file system, pass its name or the mount point to the df
command.
For example, to show the space available on the file system mounted to the system root directory (/
), you can use either df /dev/nvme0n1p3
or df /
.
df /
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p3 222284728 183057872 27865672 87% /
Show Disk Space Usage in Human Readable Format
By default, the df
command shows the disk space in 1-kilobyte blocks and the size of used and available disk space in kilobytes.
To display information about disk drives in human-readable format (kilobytes, megabytes, gigabytes and so on), invoke the df
command with the -h
option:
df -h
Filesystem Size Used Avail Use% Mounted on
dev 7.8G 0 7.8G 0% /dev
run 7.9G 1.8M 7.9G 1% /run
/dev/nvme0n1p3 212G 176G 27G 88% /
tmpfs 7.9G 145M 7.7G 2% /dev/shm
tmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup
tmpfs 7.9G 24K 7.9G 1% /tmp
/dev/nvme0n1p1 511M 106M 406M 21% /boot
/dev/sda1 459G 165G 271G 38% /data
tmpfs 1.6G 16K 1.6G 1% /run/user/1000
File System Types
The -T
option tells df
to display file system types:
df -t
The output includes an additional column named “Type” showing the type of the filesystem:
Filesystem Type 1K-blocks Used Available Use% Mounted on
dev devtmpfs 8172848 0 8172848 0% /dev
run tmpfs 8218640 1744 8216896 1% /run
/dev/nvme0n1p3 ext4 222284728 183666100 27257444 88% /
tmpfs tmpfs 8218640 383076 7835564 5% /dev/shm
tmpfs tmpfs 8218640 0 8218640 0% /sys/fs/cgroup
tmpfs tmpfs 8218640 24 8218616 1% /tmp
/dev/nvme0n1p1 vfat 523248 107912 415336 21% /boot
/dev/sda1 ext4 480588496 172832632 283320260 38% /data
tmpfs tmpfs 1643728 40 1643688 1% /run/user/1000
If you want to limit listing to file systems of a specific type use the -t
option followed by the type.
Here is an example showing how to list all ext4 partitions:
df -t ext4
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/nvme0n1p3 222284728 183666112 27257432 88% /
/dev/sda1 480588496 172832632 283320260 38% /data
Similar to above, the -x
option allows you to limit the output to file systems that are not of a specific type:
df -x tmpfs
Filesystem 1K-blocks Used Available Use% Mounted on
dev 8172848 0 8172848 0% /dev
run 8218640 1696 8216944 1% /run
/dev/nvme0n1p3 222284728 183057872 27865672 87% /
/dev/nvme0n1p1 523248 107912 415336 21% /boot
/dev/sda1 480588496 172832632 283320260 38% /data
Display Inode Usage
An inode is a data structure in Unix and Linux file systems, which contains information about a file or directory such as its size, owner, device node, socket, pipe, etc., except da.
When invoked with the -i
option, the df
command prints information about the filesystem inodes usage.
The command below will show information about the inodes on the file system mounted to system root directory /
in human-readable format:
df -ih /
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/nvme0n1p3 14M 1.9M 12M 14% /
When -i
option is used, each line of the output includes the following columns:
- “Filesystem” – The name of the filesystem.
- “Inodes” – The total number of inodes on the file system.
- “IUsed” – The number of used inodes.
- “IFree” – The number of free (unused) inodes.
- “IUse%” – The percentage of used inodes.
- “Mounted on” the directory on which the filesystem is mounted.
Output format
The df
command also allows you to customize the output format.
To specify the fields you want to be shown in the command output, use the --output[=FIELD_LIST]
option.
FIELD_LIST
is a comma-separated list of columns to be included in the output. Each field can be used only once. Valid field names are:
source
– The File system source.fstype
– The File system type.itotal
– Total number of inodes.iused
– Number of the used inodes.iavail
– Number of the available inodes.ipcent
– Percentage of used inodes.size
– Total disk space.used
– Used disk space.avail
– Available disk space.pcent
– Percentage of used space.file
– The file name if specified on the command line.target
– The mount point.
For example, to display the output of all ext4 partition in human-readable format, showing only the filesystem name and size and the percentage of the used space you would use:
df -h -t ext4 --output=source,size,pcent
Filesystem Size Use%
/dev/nvme0n1p3 212G 88%
/dev/sda1 459G 38%