How to Check Disk Space in Linux Using the df Command

Updated 

4 min read

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 based 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 information about the file system name (Filesystem), the size (1K-blocks), the used space (Used), the available space (Available), the percentage of used space (Use%), and the directory in which the filesystem is mounted (Mounted on).

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 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 view the information in human-readable format (megabytes and gigabytes), use the -h option:

df -h
Filesystem     1K-blocks      Used Available Use% Mounted on
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
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.

For example, to list all ext4 partitions you would run:

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.

Display Inode Usage

When used with the -i option the df command will display 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% /
An inode is a data structure in a 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.

Output format

The df command also allows you to specify the output format.

To limit the reported fields shown in the df 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%

Conclusion

By now you should have a good understanding of how to use the df command to get a report of the file system disk space usage.

If you want to find out the disk space usage of files and directories, use the du command.

To view all available df command options by typing man df in your terminal.