Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Shell Scripting
  • Kali Linux
  • Ubuntu
  • Red Hat
  • CentOS
  • Docker in Linux
  • Kubernetes in Linux
  • Linux interview question
  • Python
  • R
  • Java
  • C
  • C++
  • JavaScript
  • DSA
Open In App

df Command in Linux with Examples

Last Updated : 20 Mar, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

There might come a situation while using Linux when you want to know the amount of space consumed by a particular file system on your LINUX system or how much space is available on a particular file system. LINUX being command friendly provides a command line utility for this i.e. 'df' command that displays the amount of disk space available on the file system containing each file name argument.

What is the 'df' Command?

The 'df' command stands for "disk free" and is used to display information about the file systems on your Linux system. It provides a snapshot of disk usage, showing the total space, used space, available space, and the percentage of use for each mounted file system.

  • If no file name is passed as an argument with the 'df' command then it shows the space available on all currently mounted file systems
  • You should know that the df command cannot display available space on unmounted file systems. and the reason for this is that doing this on some systems requires very deep knowledge of file system structures.
  • By default, 'df' shows the disk space in 1K blocks.
  • df displays the values in the units of the first available SIZE from '--block-size' (which is an option) and from the 'DF_BLOCK_SIZE', 'BLOCKSIZE', and 'BLOCK_SIZE' environment variables.
  • By default, units are set to 1024 bytes or 512 bytes(if POSIXLY_CORRECT is set). Here, SIZE is an integer and optional unit and units are K, M, G, T, P, E, Z, Y (as K in kilo).

Syntax: 

df [OPTION]...[FILE]...
OPTION : to the options compatible with df command
FILE : specific filename in case you want to know
the disk space usage of a particular file system only.

Example:

df -h /home

-h displays disk space usage in a human-readable format (e.g., MB, GB) and /home specifies the file or directory whose file system usage you want to check.

Using the 'df' command

Suppose you have a file named kt.txt and you want to know the used disk space on the file system that contains this file then you can use df in this case as: 

// using df for a specific file //

$df kt.txt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/the2 1957124 1512 1955612 1% /snap/core

/* the df only showed the disk usage
details of the file system that
contains file kt.txt */

Now, what if you don't give any filename 't' 'df', in that case df displays the disk usage information for all mounted file systems as shown below: 

//using df without any filename //

$df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 18761008 15246876 2554440 86% /
none 4 0 4 0% /sys/fs/cgroup
udev 493812 4 493808 1% /dev
tmpfs 100672 1364 99308 2% /run
none 5120 0 5120 0% /run/lock
none 503352 1764 501588 1% /run/shm
none 102400 20 102380 1% /run/user
/dev/the2 1957124 1512 1955612 1% /snap/core

/* in this case df displayed
the disk usage details of all
mounted file systems */

Options for df command

The 'df' command comes with a variety of options that allow you to customize its output. Here are some of the most commonly used options:

OptionDescription
-a, --allIncludes all file systems, including dummy file systems with zero block sizes.
-B, --block-size=SScales sizes by the specified size (e.g., -BM shows sizes in megabytes).
--totalDisplays a grand total of all file systems.
-h, --human-readablePrints sizes in human-readable format (e.g., KB, MB, GB).
-H, --siUses powers of 1000 (e.g., kB, MB) instead of 1024.
-i, --inodesDisplays information about inodes instead of block usage.
-kDisplays file system information and usage in 1K blocks (default behavior).
-l, --localDisplays only local file systems, excluding network file systems.
-P, --portabilityUses the POSIX output format.
-t, --type=TYPEDisplays only file systems of the specified type (e.g., -t ext4).
-T, --print-typeDisplays the type of each file system.
-x, --exclude-type=TYPEExcludes file systems of the specified type from the output.
--no-syncDoes not invoke sync before getting usage info (default).
--syncInvokes sync before getting usage info, ensuring the output is fully up to date.
--helpDisplays a help message and exits.
--versionDisplays version information and exits.

-v

Ignored, included for compatibility reasons.

Examples of using 'df' with options

1. Using '-a'

If there is a need to display all file systems along with those which has zero block sizes then use -a option with df. 

//using df with -a//

$df -a
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 18761008 15246876 2554440 86% /
none 4 0 4 0% /sys/fs/cgroup
udev 493812 4 493808 1% /dev
tmpfs 100672 1364 99308 2% /run
none 5120 0 5120 0% /run/lock
none 503352 1764 501588 1% /run/shm
none 102400 20 102380 1% /run/user
/dev/sda3 174766076 164417964 10348112 95% /host
systemd 0 0 0 - /sys/fs/cgroup

/* in this case
systemd file system
having zero block
size is also displayed */

2. Using '-h'

This is used to make df command display the output in human-readable format. 

//using -h with df//

$df -h kt.txt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/the2 1.9G 1.5M 1.9G 1% /snap/core

/*this output is
easily understandable by
the user and all
cause of -h option */

In the above, G and M represents Gigabytes and Megabytes respectively. You can use '-h' with df only to produce the output in readable format for all the mounted file systems rather than just of the file system containing 'kt.txt' file. 

3. Using '-k'

This displays the file system information and usage in 1K blocks. 

//using -k with df//

$df -k kt.txt
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/the2 1957124 1512 1955612 1% /snap/core

/* no change cause the
output was initially
shown in the usage
of 1K bytes only */


4. Using '--total'

This option is used to produce total for a size, used and available columns in the output. 

//using --total with df//

$df --total
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 18761008 15246876 2554440 86% /
none 4 0 4 0% /sys/fs/cgroup
udev 493812 4 493808 1% /dev
tmpfs 100672 1364 99308 2% /run
none 5120 0 5120 0% /run/lock
none 503352 1764 501588 1% /run/shm
none 102400 20 102380 1% /run/user
/dev/the2 1957124 1512 1955612 1% /snap/core
total 21923492 15251540 5712260 92% -

/* the total row
is added in the
output */


5. Using '-T'

With the help of this option, you will be able to see the corresponding type of the file system as shown. 

/using -T with df//

$df -T kt.txt
Filesystem Type 1K-blocks Used Available Use% Mounted on
/dev/the2 squashfs 1957124 1512 1955612 1% /snap/core

/* you can use
-T with df only
to display type of
all the mounted
file systems */

6. Using '-t'

This is used when you wish the disk usage information of the file systems having a particular type only. 

//using -t with df//

$df -t squashfs
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 18761008 15246876 2554440 86% /
/dev/the2 1957124 1512 1955612 1% /snap/core


/*so the df
displayed only the
info of the file
systems having type
squashfs */

7. Using '-x'

Now, you can also tell df to display the disk usage info of all the file systems except those having a particular type with the help of '-x' option. 

//using -x with df//

$df -x squashfs
Filesystem 1K-blocks Used Available Use% Mounted on
none 4 0 4 0% /sys/fs/cgroup
udev 493812 4 493808 1% /dev
tmpfs 100672 1364 99308 2% /run
none 5120 0 5120 0% /run/lock
none 503352 1764 501588 1% /run/shm
none 102400 20 102380 1% /run/user

/* in this case info of
/dev/the2 and /dev/loop0
file systems aren't
displayed cause they are
of type squashfs */

8. Using '-i'

This option is used to display inode information in the output. 

//using -i with df//

$df -i kt.txt
Filesystem Inodes IUsed IFree Iuse% Mounted on
/dev/the2 489281 48 489233 1% /snap/core

/*showing inode info
of file system
having file kt.txt */

When -i option is used then the second, third, and fourth columns displays inode-related figures instead of disk related. 

9. Using '--sync'

By default, the df command produces output with - -no-sync option which will not perform the sync system call prior to reporting usage information. Now we can use - -sync option which will force a sync resulting in the output being fully up to date. 

//using --sync option//

$df --sync
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/loop0 18761008 15246876 2554440 86% /
none 4 0 4 0% /sys/fs/cgroup
udev 493812 4 493808 1% /dev
tmpfs 100672 1364 99308 2% /run
none 5120 0 5120 0% /run/lock
none 503352 1764 501588 1% /run/shm
none 102400 20 102380 1% /run/user
/dev/the2 1957124 1512 1955612 1% /snap/core

/* in this case
no change in the output
is observed cause it is
possible that there is no
update info present to
be reflected */

10. Using '-l'

When we run df command then by default it shows any externally mounted file systems which include those from external NFS or Samba servers. We can hide the info of these external file systems from output with -l option syntax of which is shown below.  

$df -l

Also Read:

  • 25 Basic Linux Commands For Beginners
  • Linux Interview Questions and Answer

Conclusion

The 'df' command in Linux is an essential tool for monitoring disk space usage across your system's file systems. df offers a wide range of options to cater to your needs whether you need to quickly check the available space, examine inodes, or filter by specific file system types. The 'df' command users can effectively manage disk space, prevent system overloads, and maintain overall system health. Regular use of 'df' ensures that you are aware of your system’s storage status, allowing for proactive measures in disk management and system maintenance.


K

Kartik Thakral
Improve
Article Tags :
  • Misc
  • Technical Scripter
  • Linux-Unix
  • linux-command
  • Linux-system-commands
Practice Tags :
  • Misc

Similar Reads

    'crontab' in Linux with Examples
    If you do manually backups , update logs, or restart services on your Linux machine? Imagine that running repetitive tasks overnight so your machine works for you while you rest. Here crontab, the native job scheduler in Linux, which enables users to easily automate commands, scripts, and system tas
    9 min read
    csplit command in Linux with examples
    The 'csplit' command is used to split any file into many parts as required by the user. The parts are determined by context lines. Output pieces of FILE separated by PATTERN(s) to files 'xx00', 'xx01', ..., and output byte counts of each piece to standard output.Here, we will explain how to use 'csp
    3 min read
    ctags command in Linux with examples
    The ctags command in Linux is commonly used with classic editors such as vi or vim to create an index or tags file for source code. This allows quick navigation across files, enabling users to jump to function definitions or references. ctags generates a cross-reference file that lists various sourc
    3 min read
    cupsd command in Linux with examples
    cupsd is a type of scheduler for CUPS (Common Unit Printing System). It implements the printing system on the basis of the Internet Printing Protocol(Version 2.1). If no options is being specified on the command-line then the default configuration file /etc/cups/cupsd.conf will be automatically be u
    3 min read
    curl Command in Linux with Examples
    curl is a command-line utility for transferring data to or from a server, employing a range of internet protocols such as HTTP, HTTPS, FTP, SCP, and SFTP.Whether you want to download a file, test a REST API, or simply verify that a website is up and running, curl is your best friend. It is accessed
    5 min read
    cut command in Linux with examples
    The cut command in linux is a command for cutting out the sections from each line of files and writing the result to standard output. It can be used to cut parts of a line by byte position, character, and field. The cut command slices a line and extracts the text. It is necessary to specify an optio
    8 min read
    cvs command in Linux with Examples
    In today's digital era, where file modifications and version control are essential, the Concurrent Versions System (CVS) command in Linux emerges as a powerful tool. CVS allows users to store and track the history of files, enabling easy retrieval of previous versions and restoring corrupted files.
    6 min read
    How to Display and Set Date and Time in Linux | date Command
    Unlock the full potential of the date command in Linux—a versatile tool that does more than just show the current date and time. With this command, you can set your system’s clock, synchronize time across networks, and even calculate past or future dates for tasks like scheduling or logging. In this
    8 min read
    dc command in Linux with examples
    The dc command is a versatile calculator found in Linux systems, operating using reverse Polish notation (RPN). This command allows users to perform arithmetic calculations and manipulate a stack, making it ideal for complex mathematical tasks directly from the command line.SyntaxThe basic syntax fo
    3 min read
    'dd' Command in Linux: Explained
    The dd command in Linux is a powerful utility for low-level data copying and conversion, primarily used for disk cloning, creating disk images, partition backups, and writing ISO files to USB drives. Mastering the dd command is essential for Linux system administrators, as it enables precise control
    6 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences