file system disk space usage commands

file system disk space usage commands are something we regularly checkout regularly in Linux operating system distros.

In this blog entry, I will discuss using the df command which we use to find out file system disk space usage in Linux.

df command

df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown.

Below screenshot for reference for using df command. Issue man df to see what options we have for the command and what is the use of the command.

man df file system disk space usage commands

df command usage

Example 1: df -h

When we issue df -h command in the terminal window, it will print file system sizes in powers of 1024 (e.g., 1023M) in MB’s

df -h file system disk space usage commands

This is the most common command we use to find out Free space available in the system.

Example 2: df -H

When we issue df -H command in the terminal window, it will print file system sizes in powers of 1000 (e.g., 1.1G) in GB

df -H

Both df -h and df -H are used interchangeably

file system disk space usage commands

df -a command gives details about duplicate, inaccessible file systems

df -a

Example 3: df -H /dev/sda1

Issue this command to know file system size information about a particular file system

df -H /dev/sda1 file system disk space usage commands

Example 4: df -H –output=<FIELD_LIST>

Where FIELD_LIST is a comma-separated list of columns to be included. Valid field names are: ‘source’, ‘fstype’, ‘itotal’, ‘iused’, ‘iavail’, ‘ipcent’, ‘size’, ‘used’, ‘avail’, ‘pcent’, ‘file’ and ‘target’

Issue this command to format the output where you want to see only required ones in terms of size or how much file system space is being used etc.

Ex: df -H –output=source,size,used,avail

Where in this FIELD_LIST I am using 3 fields, source,size,used,avail and below would be the output

Example 5: df -h -x tmpfs -x devtmpfs

While displaying the file system, if you want to exclude some of the disks that there is no need to look into then we can use -x attribute to validate the file system.

In this case, I have excluded viewing information about tmpfs and devtmpfs file systems.

URL for df command documentation to check more information on file system disk space usage commands, https://www.gnu.org/software/coreutils/manual/html_node/df-invocation.html

Leave a Reply

Your email address will not be published. Required fields are marked *