df Command in Linux with Examples

The df command in Linux, known as “disk free”, retrieves and displays disk space usage details for mounted file systems. It lists the device name, total, used, and available space for each mounted file system. This information offers valuable insights into storage utilization across partitions, aiding system administrators in identifying potential disk space issues.

Syntax:
The syntax for the df command in Linux is:

df [OPTION]... [FILE]...
  • Option: It refers to various command options that modify the output or behavior of the df command.
  • File: It specifies the file system(s) to be analyzed. If not provided, it displays information for all currently mounted file systems.

OPTIONS

  • -a, –all: Includes dummy file systems
  • -B, –block-size=SIZE: Use SIZE-byte blocks
  • -h, –human-readable: Print sizes in human readable format (e.g., 1K 234M 2G)
  • -H, –si: Similar to -h but uses powers of 1000 instead of 1024.
  • -i, –inodes: Lists inode information instead of block usage.
  • -k: Like –block-size=1K
  • -l, –local: Limits listing to local file systems.
  • –no-sync: Doesn’t invoke sync before obtaining usage info (default).
  • -P, –portability: Use the POSIX output format.
  • –sync: Invoke sync before getting usage info.
  • -t, –Type=Type: Limit listing to file systems of type Type.
  • -T, –print-Type: Print file system type.
  • -x, –exclude-Type=Type: Limit listing to file systems not of type Type.

df Command Examples

Example 1: Simple Example showing usage of df command

df

This command displays disk space usage details for all mounted file systems, showing device names, total, used, and available space in 1K-blocks along with the mount points.

advertisement
advertisement

Output:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23185840  51130588  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm

Example 2: Display Information of all File System Disk Space Usage

Note: Join free Sanfoundry classes at Telegram or Youtube
df -a

This command will display the information of dummy file systems along with all the file system disk usage and their memory utilization.

Output:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23186116  51130312  32% /
proc                         0         0         0   -  /proc
sysfs                        0         0         0   -  /sys
devpts                       0         0         0   -  /dev/pts
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm
none                         0         0         0   -  /proc/sys/fs/binfmt_misc
sunrpc                       0         0         0   -  /var/lib/nfs/rpc_pipefs

Example 3: Display Disk Space Usage in Human Readable Format

advertisement
df -h

It shows disk space usage in a human-readable format (sizes in GB, MB, etc.) for all mounted file systems with 1K-blocks and mount points.

Output:

Filesystem            Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p2      75G   23G   49G  32% /
/dev/cciss/c0d0p5      24G   22G  1.2G  95% /home
/dev/cciss/c0d0p3      29G   25G  2.6G  91% /data
/dev/cciss/c0d0p1     289M   22M  253M   8% /boot
tmpfs                 252M     0  252M   0% /dev/shm

Example 4: Display Information of /home

advertisement
df -hT /home

This command displays information for the /home directory in a human-readable format, along with the file system type, showing sizes, usage, and mount point.

Output:

Filesystem		Type    Size  Used Avail Use% Mounted on
/dev/cciss/c0d0p5	ext3     24G   22G  1.2G  95% /home

Example 5: Display Information of File System in Bytes

df -k

It displays all file system information and usage in 1024-byte blocks, indicating sizes, usage, and mount points.

Output:

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2     78361192  23187212  51129216  32% /
/dev/cciss/c0d0p5     24797380  22273432   1243972  95% /home
/dev/cciss/c0d0p3     29753588  25503792   2713984  91% /data
/dev/cciss/c0d0p1       295561     21531    258770   8% /boot
tmpfs                   257476         0    257476   0% /dev/shm

Example 6: Display Information of File System in MB

df -m

-m option displays file system information in megabytes (MB), indicating sizes, usage, and mount points.

Output:

Filesystem           1M-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p2        76525     22644     49931  32% /
/dev/cciss/c0d0p5        24217     21752      1215  95% /home
/dev/cciss/c0d0p3        29057     24907      2651  91% /data
/dev/cciss/c0d0p1          289        22       253   8% /boot
tmpfs                      252         0       252   0% /dev/shm

Example 7: Display File System Inodes

df -i

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

Output:

Filesystem            Inodes   IUsed   IFree IUse% Mounted on
/dev/cciss/c0d0p2    20230848  133143 20097705    1% /
/dev/cciss/c0d0p5    6403712  798613 5605099   13% /home
/dev/cciss/c0d0p3    7685440 1388241 6297199   19% /data
/dev/cciss/c0d0p1      76304      40   76264    1% /boot
tmpfs                  64369       1   64368    1% /dev/shm

Example 8: Display File System Type

df -T

The -T option displays file system types along with their 1K-block usage, indicating sizes, usage, and mount points.

Output:

Filesystem		Type   1K-blocks  Used      Available Use% Mounted on
/dev/cciss/c0d0p2	ext3    78361192  23188812  51127616  32%   /
/dev/cciss/c0d0p5	ext3    24797380  22273432  1243972   95%   /home
/dev/cciss/c0d0p3	ext3    29753588  25503792  2713984   91%   /data
/dev/cciss/c0d0p1	ext3    295561     21531    258770    8%    /boot
tmpfs			tmpfs   257476         0    257476    0%   /dev/shm

Example 9: Exclude Certain File System Type

df -x ext3

This command displays disk space usage details for all file systems excluding those of type ext3. It lists device names, total, used, and available space for the file systems, but excludes those of the specified type (ext3 in this case).

Output:

Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                   257476         0    257476   0% /dev/shm

Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.