Check your disk space use with the Linux df command

0 0
Read Time:3 Minute, 45 Second

Two related commands that every system administrator runs frequently are df and du. While du reports files’ and directories’ disk usage, df reports how much disk space your filesystem is using. The df command displays the amount of disk space available on the filesystem with each file name’s argument.

For a good overview of the du command, read Tyler Carrigan’s article Linux commands: du and the options you should be using. You might also be interested in my article Make du’s output more useful with this neat trick.

This article discusses how to use the df command.

Learn df’s syntax

The df command can be run by any user. Like many Linux commands, df uses the following structure:

df [OPTION]... [FILE]...

The df command primarily checks disk usage on a mounted filesystem. If you don’t include a file name, the output shows the space available on all currently mounted filesystems. Disk space is shown in 1K blocks by default:

$ df
Filesystem    1K-blocks    Used Available Use% Mounted on
devtmpfs         883500       0    883500   0% /dev
tmpfs            913840     168    913672   1% /dev/shm
tmpfs            913840    9704    904136   2% /run
tmpfs            913840       0    913840   0% /sys/fs/cgroup
/dev/map[...]  17811456 7193312  10618144  41% /
/dev/sda1       1038336  260860    777476  26% /boot
tmpfs            182768     120    182648   1% /run/user/1000

Lists of long numbers (as shown above) can be difficult to parse. If you want to run df in its human-readable format, use the --human-readable (-h for short) option:

$ df -h
Filesystem    Size  Used Avail Use% Mounted on
devtmpfs       863M     0  863M   0% /dev
tmpfs          893M  168K  893M   1% /dev/shm
tmpfs          893M  9.5M  883M   2% /run
tmpfs          893M     0  893M   0% /sys/fs/cgroup
/dev/map[...]   17G  6.9G   11G  41% /
/dev/sda1     1014M  255M  760M  26% /boot
tmpfs          179M  120K  179M   1% /run/user/1000

Get inodes

To show inode (or index node) use on each mounted filesystem, use --inodes (-i for short):

$ df -ih
Filesystem    Inodes IUsed IFree IUse% Mounted on
devtmpfs        216K   393  216K    1% /dev
tmpfs           224K     3  224K    1% /dev/shm
tmpfs           224K   857  223K    1% /run
tmpfs           224K    17  224K    1% /sys/fs/cgroup
/dev/map[...]   8.5M  168K  8.4M    2% /
/dev/sda1       512K   310  512K    1% /boot
tmpfs           224K    74  224K    1% /run/user/1000

[ Learn about Bash’s rich features by downloading the Bash shell scripting cheat sheet. ]

Get total available space

To omit entries that aren’t essential to available space and get a total, use the --total option. You can use this option when all mounted filesystems are on the same disk, whether physical or virtual:

$ df -h --total
Filesystem     Size  Used Avail Use% Mounted on
devtmpfs       863M     0  863M   0% /dev
tmpfs          893M  168K  893M   1% /dev/shm
tmpfs          893M  9.5M  883M   2% /run
tmpfs          893M     0  893M   0% /sys/fs/cgroup
/dev/map[...]   17G  6.9G   11G  41% /
/dev/sda1     1014M  255M  760M  26% /boot
tmpfs          179M  120K  179M   1% /run/user/1000
total           22G  7.2G   15G  33% -

If you want to omit all mount points except for the total, use grep alongside a regular expression with ^ to search for the total at the start of a line:

$ df -h --total|grep ^total
total           22G  7.2G   15G  33% -

Get disk space available on a specific mount

You can also run df on a specific mount point:

$ df -h /
Filesystem                Size  Used Avail Use% Mounted on
/dev/mapper/centos-stream  17G  6.9G   11G  41% /

$ df -h /boot
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1      1014M  255M  760M  26% /boot

Customize your output

The examples I’ve demonstrated so far have the same columns in the output. If you want different output, you can customize the fields. For instance, suppose you don’t want to see the size or amount of disk used:

$ df -h --output=source,avail,pcent,target
Filesystem      Avail Use%  Mounted on
devtmpfs         863M   0%  /dev
tmpfs            893M   1%  /dev/shm
tmpfs            883M   2%  /run
tmpfs            893M   0%  /sys/fs/cgroup
/dev/map[...]     11G  41%  /
/dev/sda1        760M  26%  /boot
tmpfs            179M   1%  /run/user/1000

You can read about the available field options on the info page and the man page.

[ You may also be interested in downloading the Curl command cheat sheet. ]

Use df

It’s a good idea to use the df command regularly to monitor usage on critical mount points. These are the ways I typically use the command, so find your favorite options and start gathering data about your system.

Image

Loading

Happy
Happy
0 %
Sad
Sad
0 %
Excited
Excited
0 %
Sleepy
Sleepy
0 %
Angry
Angry
0 %
Surprise
Surprise
0 %

About Author

  • Related Posts

    Average Rating

    5 Star
    0%
    4 Star
    0%
    3 Star
    0%
    2 Star
    0%
    1 Star
    0%

    Incase you missed

    Explainer : What Proxies are and their usage

    Explainer : What Proxies are and their usage

    MPESA consumer, secret and passkeys {Safaricom M-pesaWeBPortal} for API integration {Daraja 2.0}

    MPESA consumer, secret and passkeys {Safaricom M-pesaWeBPortal} for API integration {Daraja 2.0}

    [LINKTREE] 2024 PAST PAPERS , NOTES ,RESOURCE,REVISION,EXAMINATIONS

    [LINKTREE] 2024 PAST PAPERS , NOTES ,RESOURCE,REVISION,EXAMINATIONS

    2024 PAST PAPERS , NOTES ,RESOURCE,REVISION,EXAMINATIONS

    2024 PAST PAPERS , NOTES ,RESOURCE,REVISION,EXAMINATIONS

    Shipbrokers Breach of Authority

    Shipbrokers Breach of Authority

    Explain classification of law

    Explain classification of law

    Maritime Terms, Abbreviations and Acronyms [Shipping Terms – Searchable]

    Maritime Terms, Abbreviations and Acronyms [Shipping Terms – Searchable]

    Maritime Terms, Abbreviations and Acronyms [ Shipping Terms]

    Maritime Terms, Abbreviations and Acronyms [ Shipping Terms]

    KCB BANK CODES ACROSS KENYA BY REGION tabular

    KCB BANK CODES ACROSS KENYA BY REGION tabular

    Optimizing Container Stowage Plan for Efficient Cargo Placement on Ships

    Optimizing Container Stowage Plan for Efficient Cargo Placement on Ships

    Choosing Between Managed and Unmanaged Services

    Choosing Between Managed and Unmanaged Services

    Differences Between Managed and UnManaged Services

    Differences Between Managed and UnManaged Services

    How to check KRA PIN using BRS (Ecitizen)

    How to check KRA PIN using BRS (Ecitizen)

    HTML ERROR MESSAGES

    HTML ERROR MESSAGES

    DISCUSS THE SYSTEM OF COURTS IN KENYA

    DISCUSS THE SYSTEM OF COURTS IN KENYA

    GLOSSARY ON INTERNET TERMS

    GLOSSARY ON INTERNET TERMS

    KEYBOARD SHORTCUTS

    KEYBOARD SHORTCUTS

    NESTICT LMS: INTERNET NOTES

    NESTICT LMS: INTERNET NOTES

    REPORTED SPEECH

    REPORTED SPEECH

    [Explainer]: NVMe storage, SSD (SATA SSD), and HDD

    [Explainer]: NVMe storage, SSD (SATA SSD), and HDD

    SSD vs HDD: What’s the difference?

    SSD vs HDD: What’s the difference?

    Enabling Hyper-V on Windows 10

    Enabling Hyper-V on Windows 10

    Discussion : Windows 10 Virtualization

    Discussion : Windows 10 Virtualization

    BLUETOOTH LAN NETWORK

    BLUETOOTH LAN NETWORK

    PROS CONS AND WAYS OF INVESTING IN BITCOIN

    PROS CONS AND WAYS OF INVESTING IN BITCOIN

    What is a cloud service provider

    What is a cloud service provider

    Application Service Provider (ASP) Meaning

    Application Service Provider (ASP) Meaning

    POSTAL CODES – Updated as at July 2024 – PDF

    POSTAL CODES – Updated as at July 2024 – PDF

    POSTAL CODES – Updated as at July 2024

    POSTAL CODES – Updated as at July 2024

    Check your disk space use with the Linux df command

    Check your disk space use with the Linux df command

    Best Places to get Accounting Internship Opportunities

    Best Places to get Accounting Internship Opportunities

    Top Kenyan Based Companies to apply for internship

    Top Kenyan Based Companies to apply for internship

    Credit Scores Quickk FAQs

    Credit Scores Quickk FAQs

    Credit Score Ranges: What Do They Mean?

    Credit Score Ranges: What Do They Mean?

    RANDOMIZING PHONE NUMBERS IN EXCEL

    RANDOMIZING PHONE NUMBERS IN EXCEL

    [Updated 2024] – Passport Application FOR CHILDREN ONLY(PERSONS UNDER 18 YEARS)

    [Updated 2024] – Passport Application FOR CHILDREN ONLY(PERSONS UNDER 18 YEARS)

    [Updated 2024] -Passport Application FOR ADULTS ONLY-PERSONS OVER 18 YEARS

    [Updated 2024] -Passport Application FOR ADULTS ONLY-PERSONS OVER 18 YEARS

    Understanding Tires Load Index vs Load Range on Car Tires

    Understanding Tires Load Index vs Load Range on Car Tires

    Computer Bus: Video

    Computer Bus: Video

    Computer Bus

    Computer Bus

    Types of Computer Network Topology Explained With Diagrams

    Types of Computer Network Topology Explained With Diagrams

    The Functions of PCI Slots

    The Functions of PCI Slots

    Complementary Metal Oxide Semiconductor – CMOS

    Complementary Metal Oxide Semiconductor – CMOS

    The Computer Motherboard and Its Components Explained

    The Computer Motherboard and Its Components Explained

    AI in Education is Best Experiences

    AI in Education is Best Experiences

    Harnessing the Power of Wind Energy

    Harnessing the Power of Wind Energy

    The Golden Gate’s Timeless Majesty

    The Golden Gate’s Timeless Majesty

    Rise of Competitive Video Gaming

    Rise of Competitive Video Gaming

    Ultimate Sports Ground Experience

    Ultimate Sports Ground Experience

    Global Ocean Cleanup Initiatives

    Global Ocean Cleanup Initiatives

    The Enduring Appeal of Gaming Classics

    The Enduring Appeal of Gaming Classics

    The Art of Mindful Eating

    The Art of Mindful Eating

    Classic Video Games Making a Comeback

    Classic Video Games Making a Comeback

    Sustainable Travel for Eco-Friendly Tourism

    Sustainable Travel for Eco-Friendly Tourism

    Mind-Body Connection for Meditation

    Mind-Body Connection for Meditation

    Future of Work Like Remote Collaboration Tools

    Future of Work Like Remote Collaboration Tools

    Innovations in 3D Printing

    Innovations in 3D Printing

    Digital Detox Unplug and Reconnect

    Digital Detox Unplug and Reconnect

    Crafting Engaging Audio Experiences

    Crafting Engaging Audio Experiences

    Advancements in Digital Camera

    Advancements in Digital Camera