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
- Show Disk Space in Human-Readable Format
- Include Filesystem Type
- Display Inode Usage Instead of Disk Space
- Show Disk Space for a Specific Filesystem
- Exclude Specific Filesystem Types
- Display Disk Space in 1K Blocks
- Show Disk Space in Megabytes
- Include Pseudo, Duplicate, or Inaccessible Filesystems
- Display Total Disk Usage Summary
- Show Disk Space for Remote Filesystems (NFS, SMB)
- Refresh Output Continuously
- Display Filesystem Usage in JSON Format
- Show Disk Space for a Specific Directory
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.