Signup/Sign In

How to Check Disk Space in Linux Using Df Command

You can use the df command on Linux and Unix operating systems to acquire a thorough report on the system’s disk space consumption.

Using the df Command

The general syntax for the df command is as follows:

df [OPTIONS]... FILESYSTEM...

When used without any parameter, the df program will provide information about all mounted file systems :

$df

Output

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 has the following columns:

“Filesystem” – The name of the filesystem.
“1K-blocks” - The size of the filesystem in 1K blocks.
“Utilized” - The used space in 1K blocks.
“Available” - The available space in 1K blocks.
“Use per cent” – The proportion of utilized space.
“Mounted on” is the directory on which the filesystem is mounted.

To show information exclusively for a particular file system, supply its name or the mount point to the df command.
For example, to see the space available on the file system mounted to the system root directory (/), you may 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 program displays the disk space in 1-kilobyte blocks and the amount of utilized and available disk space in kilobytes.

To show information about disk devices in human-readable format (kilobytes, megabytes, gigabytes, and so on), use 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 instructs df to list file system types:

df -t

The report adds an extra column entitled “Kind,” indicating the type of the filesystem:

Output

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 wish to restrict the listing to file systems of a specific type, use the -t option followed by the kind.

Here is an example demonstrating how to display all ext4 partitions:

df -t ext4

Output:

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 enables you to restrict the output to file systems that are not of a specified type:

df -x tmpfs

Output:

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 holds information on a file or directory such as its size, owner, device node, socket, pipe, etc., except da.

When used with the -i option, the df command provides information on the filesystem inodes usage.

The command below will reveal information about the inodes on the file system mounted to system root directory / in human-readable format:

df -ih /

Output:

Filesystem     Inodes IUsed IFree IUse% Mounted on
/dev/nvme0n1p3    14M  1.9M   12M   14% /

When the -I option is used, each line of the output contains the following columns:

“Filesystem” – The name of the filesystem.

“Inodes” - The total amount of inodes on the file system.

“I used” - The number of utilized inodes.

“IFree” - The number of free (unused) inodes.

“IUse percent ” – The proportion of utilized inodes.

“Mounted on” is the directory on which the filesystem is mounted.

Output format

The df command also enables you to change the output format.

To define the fields you wish to be presented in the command output, use the —output[=FIELD LIST] option.

FIELD LIST is a comma-separated list of columns in the output. Each field may 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 utilized inodes.

Size - Total disk space.

Used - Used disk space.

Available - Available disk space.

pcent - Percentage of utilized space.

File: The file name is given on the command line.

target - The mount point.

For example, to display the output of every ext4 partition in human-readable format, revealing just the filesystem name and size and the percentage of the utilized space you would use:

df -h -t ext4 —output=source,size,pcent

Output:

Filesystem      Size Use%
/dev/nvme0n1p3  212G  88%
/dev/sda1       459G  38%

Conclusion

We’ve taught you how to use the df command to receive a report on the filesystem disk space use. To read all possible df command options by entering man df on your terminal.

To find out the disk space utilization of files and directories, use the du program.