Linux df Command: Disk Space Reporting

LinuxLinuxBeginner
Practice Now

Introduction

This tutorial provides an introduction to the df command in Linux, a utility that displays information about disk space usage on mounted file systems.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/SystemInformationandMonitoringGroup -.-> linux/df("`Disk Space Reporting`") subgraph Lab Skills linux/df -.-> lab-219188{{"`Linux df Command: Disk Space Reporting`"}} end

df Command

The df command is a vital tool for checking disk space usage on Linux systems. It provides valuable information about the size, used space, available space, and percentage of usage for each mounted file system.

Command Usage

Let's begin by understanding the basic usage of the df command. The df command is used to display disk space usage information for mounted file systems.

terminal

Input:

df

Output:

Filesystem     1K-blocks     Used Available Use% Mounted on
overlay         20971520   128828  20842692   1% /
tmpfs              65536        0     65536   0% /dev
tmpfs            3995004        0   3995004   0% /sys/fs/cgroup
shm                65536        0     65536   0% /dev/shm
/dev/vdb       104806400 27097676  77708724  26% /etc/hosts

In this example, the df command displays information about the disk space usage on mounted file systems.

Parameters and Usage Examples

The df command provides options to customize the output and focus on specific information.

Option Parameter

df [option] file

  • -h: Easy-to-read display.
  • -T: Display file system types.
  • -i: Show inode information.

Example Usage

1. Display Total Summary (-h)

The df command can be configured to display a total summary of all file systems. In this example, we will show the total disk space usage summary:

Input:

df -h --total

Output:

Filesystem      Size  Used Avail Use% Mounted on
overlay          20G  126M   20G   1% /
tmpfs            64M     0   64M   0% /dev
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
shm              64M     0   64M   0% /dev/shm
/dev/vdb        100G   26G   75G  26% /etc/hosts
total           124G   26G   98G  21% -

2. Display File System Types (-T)

The df command can be configured to display the file system type along with disk space information. In this example, we will display the file system type for each mounted file system:

Input:

df -T

Output:

Filesystem     Type    1K-blocks     Used Available Use% Mounted on
overlay        overlay  20971520   128872  20842648   1% /
tmpfs          tmpfs       65536        0     65536   0% /dev
tmpfs          tmpfs     3995004        0   3995004   0% /sys/fs/cgroup
shm            tmpfs       65536        0     65536   0% /dev/shm
/dev/vdb       xfs     104806400 27097876  77708524  26% /etc/hosts

3. Display Inodes Information (-i)

You can use the df command to display information about inodes, the data structures on a file system that store information about files and directories. In this example, we will show inodes information for each mounted file system:

Input:

df -i

Output:

Filesystem       Inodes  IUsed    IFree IUse% Mounted on
overlay        52428800 900951 51527849    2% /
tmpfs            998751    205   998546    1% /dev
tmpfs            998751     17   998734    1% /sys/fs/cgroup
shm              998751      1   998750    1% /dev/shm
/dev/vdb       52428800 900951 51527849    2% /etc/hosts

Summary

The df command is an essential tool for monitoring and managing disk space usage on Linux systems. Whether you need to display file system types, inodes information, or a total summary of disk space usage, the df command provides valuable insights for system administrators and users alike.

Other Linux Tutorials you may like