Useful “df” Commands to Check Disk Space in Linux

Useful “df” Commands to Check Disk Space in Linux

In the world of Linux systems administration, monitoring and managing disk space is a critical task. The df command is a powerful tool that provides essential information about disk usage on Linux systems. On the internet, you will find plenty of tools for checking disk space utilization in Linux.

The df command stands for “disk free” and is used to display information about available and used disk space on Linux systems. It provides a summary of filesystem usage, including the total size, used space, available space, and the mount point of each filesystem.

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. In this article, we will explore the df command in depth, discussing its usage, options, and practical examples.

1. Check File System 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.

df
Filesystem     512-blocks      Used Available Capacity iused      ifree %iused  Mounted on
/dev/disk1s1s1  976490576  17725680 559478496     4%  356093 2797392480    0%   /
devfs                 377       377         0   100%     652          0  100%   /dev
/dev/disk1s3    976490576   4322480 559478496     1%    2268 2797392480    0%   /System/Volumes/Preboot
/dev/disk1s5    976490576   4194360 559478496     1%       2 2797392480    0%   /System/Volumes/VM
/dev/disk1s6    976490576     21904 559478496     1%      16 2797392480    0%   /System/Volumes/Update
/dev/disk1s2    976490576 388192304 559478496    41% 2066872 2797392480    0%   /System/Volumes/Data
map auto_home           0         0         0   100%       0          0  100%   

2. Display Information on all File System Disk Space Usage

The same as above, but it also displays information on dummy file systems along with all the file system disk usage and their memory utilization.

df -a
Filesystem     512-blocks      Used Available Capacity iused      ifree %iused  Mounted on
/dev/disk1s1s1  976490576  17725680 559494152     4%  356093 2797470760    0%   /
devfs                 377       377         0   100%     652          0  100%   /dev
/dev/disk1s3    976490576   4322480 559494152     1%    2268 2797470760    0%   /System/Volumes/Preboot
/dev/disk1s5    976490576   4194360 559494152     1%       2 2797470760    0%   /System/Volumes/VM
/dev/disk1s6    976490576     21904 559494152     1%      16 2797470760    0%   /System/Volumes/Update
/dev/disk1s2    976490576 388176648 559494152    41% 2066964 2797470760    0%   /System/Volumes/Data
map auto_home           0         0         0   100%       0          0  100%   /System/Volumes/Data/home

3. Show Disk Space Usage in Human Readable Format

-h or --human-readable: Displays the output in a human-readable format, using units like kilobytes (K), megabytes (M), and gigabytes (G).

df -h
Filesystem       Size   Used  Avail Capacity iused      ifree %iused  Mounted on
/dev/disk1s1s1  466Gi  8.5Gi  267Gi     4%  356093 2797384680    0%   /
devfs           189Ki  189Ki    0Bi   100%     652          0  100%   /dev
/dev/disk1s3    466Gi  2.1Gi  267Gi     1%    2268 2797384680    0%   /System/Volumes/Preboot
/dev/disk1s5    466Gi  2.0Gi  267Gi     1%       2 2797384680    0%   /System/Volumes/VM
/dev/disk1s6    466Gi   11Mi  267Gi     1%      16 2797384680    0%   /System/Volumes/Update
/dev/disk1s2    466Gi  185Gi  267Gi    41% 2067166 2797384680    0%   /System/Volumes/Data
map auto_home     0Bi    0Bi    0Bi   100%       0          0  100%   /System/Volumes/Data/home

4. Display Information of File System in Bytes

To display all file system information and usage in 1024-byte blocks, use the option ‘-k‘ (e.g. --block-size=1K) as follows.

df -k
Filesystem     1024-blocks      Used Available Capacity iused      ifree %iused  Mounted on
/dev/disk1s1s1   488245288   8862840 279741428     4%  356093 2797414280    0%   /
devfs                  188       188         0   100%     652          0  100%   /dev
/dev/disk1s3     488245288   2161244 279741428     1%    2268 2797414280    0%   /System/Volumes/Preboot
/dev/disk1s5     488245288   2097180 279741428     1%       2 2797414280    0%   /System/Volumes/VM

5. Display Information of File System in MB

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

df -m
Filesystem     1M-blocks   Used Available Capacity iused      ifree %iused  Mounted on
/dev/disk1s1s1    476802   8655    273178     4%  356093 2797345920    0%   /
devfs                  0      0         0   100%     652          0  100%   /dev

6. Display File System Inodes

Using ‘-i‘ switch will display the information of a number of used inodes and their percentage for the file system.

df -i
Filesystem     512-blocks      Used Available Capacity iused      ifree %iused  Mounted on
/dev/disk1s1s1  976490576  17725680 559468272     4%  356093 2797341360    0%   /
devfs                 377       377         0   100%     652          0  100%   /dev

Read Also:

ncdu command

Leave a Reply