12 Linux ‘df’ Commands to Check Disk Space Usage

On the internet, you will find plenty of tools for checking disk space usage in Linux. However, Linux has a strong built-in utility called ‘df‘.

The ‘df‘ command stands for “disk filesystem“, it is used to get a full summary of available and used disk space usage of the file system on the Linux system.

Using ‘-h‘ parameter with (df -h) will show the file system disk space statistics in “human-readable” format, which means it gives the details in bytes, megabytes, and gigabytes.

This article explains how to get the full information on Linux disk space usage with the help of the ‘df‘ command with their practical examples. So, you could better understand the usage of the df command in Linux.

1. Check Linux Disk Space Usage

The “df” command displays the information of device name, total blocks, total disk space, used disk space, available disk space, and mount points on a file system.

sudo df
Show Linux Disk Space Usage
Show Linux Disk Space Usage

2. Check Information on Linux Disk Space Usage

The command "df -a" is used to display information about all the mounted filesystems disk space usage, which includes total space, used space, available space, memory utilization, and the percentage of space used for each filesystem.

It also shows pseudo filesystems with 0 blocks (those not directly tied to a physical device) and are ignored by default.

df -a
Show Information of Disk Space Usage
Show Information on Disk Space Usage

3. Show Disk Space Usage in Human Readable Format

Have you noticed that the above commands display information in bytes, which is not readable at all because we are in a habit of reading the sizes in megabytes, gigabytes, etc. as it makes it very easy to understand and remember.

The command "df -h" is used to display disk space usage in a human-readable format. The "-h" option stands for “human-readable” and it shows information about all mounted filesystems on your system, presenting the sizes in a format that is easier for humans to understand, using units like kilobytes (KB), megabytes (MB), gigabytes (GB), etc.

sudo df -h
Show Disk Usage in Human-Readable Format
Show Disk Usage in Human-Readable Format

4. Check Disk Space Usage of /home Directory

The command "df -hT /home" is used to display disk space utilization of /home directory or partition in a human-readable format. The -T option shows the filesystem type (ext4) along with other information.

df -hT /home
Check /home Directory Disk Space
Check /home Directory Disk Space

5. Check Disk Space Usage in Kilobytes

To display all mounted filesystem information and usage in 1024-byte blocks, use the option ‘-k‘ (e.g. --block-size=1K), which provides information about each filesystem on your system, presenting sizes in kilobytes (kb).

sudo df -k
Disk Space Usage in Kilobytes
Disk Space Usage in Kilobytes

6. Check Disk Space Usage in Megabytes

To display information on all file system usage in MB (MegaByte) use the option ‘-m‘, which presents sizes in megabytes (MB).

sudo df -m
Disk Space Usage in Megabytes
Disk Space Usage in Megabytes

7. Check Disk Space Usage in Gigabyte

To display information on all file system statistics in GB (Gigabyte) use the command "df -h", which shows disk space in human-readable sizes such as kilobytes (KB), megabytes (MB), gigabytes (GB), and so on.

sudo df -h
Disk Space Usage in Gigabytes
Disk Space Usage in Gigabytes

8. Check Inode Usage in Linux

The command "df -i" provides detailed information about the number of inodes used and available on each mounted filesystem on a Linux system. The inodes are data structures that store information about files and directories, such as ownership, permissions, and timestamps.

sudo df -i
Check Inode Usage in Linux
Check Inode Usage in Linux

If you find yourself in a situation where there is a shortage of inodes, you will need to increase the inode count on your Linux filesystem.

9. Check Linux File System Type

If you notice all the above commands output, you will see there is no Linux file system type mentioned in the results. To check the file system type of your system use the option ‘T‘, which will display file system type along with other information.

sudo df -T
Show File System Type
Show File System Type

10. Check Disk Space Usage for ext4 Filesystems

If you want to display a certain file system type use the ‘-t‘ option, which will display disk space usage specifically for filesystems of type ext4.

sudo df -t ext4
Check Filesystem Type Disk Usage
Check Filesystem Type Disk Usage

11. Exclude Certain File System Type

If you want to display a file system type that doesn’t belong to the ext4 type, use the option ‘-x‘, which will print disk space usage for all mounted non-ext4 filesystem filesystems excluding those of type ext4.

sudo df -x ext4
Exclude File System Type
Exclude File System Type

12. Check df Command Usage

The command "df --help" provides a list of available option that is used with the df command.

df --help
df Command Help
df Command Help
Conclusion

The ‘df‘ command is useful for checking disk space utilization on your Linux system. By running various options such as '-h' for human-readable output or '-T' to display filesystem types, users can obtain detailed information about the disk space usage across different mounted filesystems.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Ravi Saive
I am an experienced GNU/Linux expert and a full-stack software developer with over a decade in the field of Linux and Open Source technologies

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.