How to Check Disk Usage of Linux File System

The df (disk filesystem) command in Linux is used to display information about disk space usage for mounted filesystems. It provides details such as total space, used space, available space, and the percentage of usage for each partition.

Alby Andersen

The df command in Linux displays disk space usage for mounted filesystems. It provides insights into total, used, and available space, helping you monitor storage and prevent overflows.


Display Disk Space Usage for All Filesystems

df  


Shows disk usage for all mounted filesystems in 1K blocks.


Show Disk Space in Human-Readable Format

df -h  
  • -h: Displays sizes in KB, MB, or GB for easier reading.

Include Filesystem Type

df -Th  
  • -T: Adds the filesystem type (e.g., ext4, tmpfs).
  • -h: Human-readable format.

Display Inode Usage Instead of Disk Space

df -i  


Shows inode usage (number of used and free inodes).


Show Disk Space for a Specific Filesystem

df -h /dev/sda1  


Displays disk usage for the /dev/sda1 partition.


Exclude Specific Filesystem Types

df -h -x tmpfs -x devtmpfs  
  • -x: Excludes filesystems of the specified type (e.g., tmpfs, devtmpfs).

Display Disk Space in 1K Blocks

df -k  
  • -k: Shows sizes in 1K blocks (default behavior).

Show Disk Space in Megabytes

df -m  
  • -m: Displays sizes in MB.

Include Pseudo, Duplicate, or Inaccessible Filesystems

df -a  
  • -a: Includes pseudo, duplicate, or inaccessible filesystems.

Display Total Disk Usage Summary

df --total  


Adds a total line summarizing disk usage across all filesystems.


Show Disk Space for Remote Filesystems (NFS, SMB)

df -h /mnt/nfs_share  


Displays disk usage for a mounted remote filesystem.


Refresh Output Continuously

watch -n 1 df -h  
  • watch: Refreshes the output every second.

Display Filesystem Usage in JSON Format

df --output=source,fstype,size,used,avail,pcent -h  
  • --output: Customizes columns (e.g., source, fstype, size, used, avail, pcent).

Show Disk Space for a Specific Directory

df -h /var/log  


Displays disk usage for the filesystem containing /var/log.


Key Notes:

  • Human-Readable Format: Always use -h for easier interpretation.
  • Inodes: Use -i to monitor inode usage, especially for filesystems with many small files.
  • Remote Filesystems: Ensure remote mounts (e.g., NFS) are accessible for accurate results.
Share This Article