0% found this document useful (0 votes)
9 views

Check Your Disk Space Use With The Linux DF Command

Uploaded by

yash.kumar.98052
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Check Your Disk Space Use With The Linux DF Command

Uploaded by

yash.kumar.98052
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

Create an account or log in to access


your product trials, support cases, and
more in the My Red Hat dashboard.

Check your disk space use


with the Linux df command
March 23, 2022 Evans Amoany 5-minute read

Linux
https://w w w .redhat.com/en/blog/linux-df-command 1/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

SHARE

< Back to all posts

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
Red Hat Blog Menu
your filesystem is using. The df command displays the
amount of disk space available on the filesystem with
each file name's argument.
https://w w w .redhat.com/en/blog/linux-df-command 2/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

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]...

https://w w w .redhat.com/en/blog/linux-df-command 3/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

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 Us
devtmpfs 883500 0 883500 0
tmpfs 913840 168 913672
tmpfs 913840 9704 904136
tmpfs 913840 0 913840 0
/dev/map[...] 17811456 7193312 10618144 4

https://w w w .redhat.com/en/blog/linux-df-command 4/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

/dev/sda1 1038336 260860 777476 2


tmpfs 182768 120 182648

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 o
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
https://w w w .redhat.com/en/blog/linux-df-command 5/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

/dev/map[...] 17G 6.9G 11G 41% /


/dev/sda1 1014M 255M 760M 26% /boot
tmpfs 179M 120K 179M 1% /run/us

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% Mount
devtmpfs 216K 393 216K 1% /dev

https://w w w .redhat.com/en/blog/linux-df-command 6/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

tmpfs 224K 3 224K 1% /dev/


tmpfs 224K 857 223K 1% /run
tmpfs 224K 17 224K 1% /sys/f
/dev/map[...] 8.5M 168K 8.4M 2% /
/dev/sda1 512K 310 512K 1% /boot
tmpfs 224K 74 224K 1% /run/

[ Learn about Bash's rich features by downloading the


Bash shell scripting cheat sheet. ]

Get total available space

https://w w w .redhat.com/en/blog/linux-df-command 7/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

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
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
/dev/map[...] 17G 6.9G 11G 41% /
/dev/sda1 1014M 255M 760M 26% /boot
https://w w w .redhat.com/en/blog/linux-df-command 8/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

tmpfs 179M 120K 179M 1% /run/us


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
https://w w w .redhat.com/en/blog/linux-df-command 9/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

You can also run df on a specific mount point:

$ df -h /
Filesystem Size Used Avail U
/dev/mapper/centos-stream 17G 6.9G 11G 4

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

Customize your output


https://w w w .redhat.com/en/blog/linux-df-command 10/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

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% /

https://w w w .redhat.com/en/blog/linux-df-command 11/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

/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

https://w w w .redhat.com/en/blog/linux-df-command 12/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

ways I typically use the command, so find your favorite


options and start gathering data about your system.

ABOUT THE AUTHOR

Evans Amoany
I work as Unix/Linux
Administrator with a passion for
high availability systems and
clusters. I am a student of
https://w w w .redhat.com/en/blog/linux-df-command 13/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

performance and optimization


of systems and DevOps. I have
passion for anything IT related
and most importantly
automation, high availability,
and security.

Read full bio

More like this


https://w w w .redhat.com/en/blog/linux-df-command 14/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

BLOG POST

Tame complexity with Red Hat Enterprise Linux 9.5

BLOG POST

Bringing Red Hat Enterprise Linux to Windows Subsystem for


Linux

ORIGINAL SHOWS

OS Wars_part 2: Rise of Linux | Command Line Heroes

ORIGINAL SHOWS

https://w w w .redhat.com/en/blog/linux-df-command 15/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

OS Wars_part 1 | Command Line Heroes

Keep exploring
E-book: Managing infrastructure at cloud scale
E-book: Build an efficient IT foundation for
modern business success
Free trial: Red Hat Learning Subscription

https://w w w .redhat.com/en/blog/linux-df-command 16/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

Browse by Explore all


channel channels

https://w w w .redhat.com/en/blog/linux-df-command 17/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

Automation Artificial
intelligence
The latest on
IT automation Updates on
for tech, the platforms
teams, and that free
environments customers to
run AI
workloads
anywhere

https://w w w .redhat.com/en/blog/linux-df-command 18/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

https://w w w .redhat.com/en/blog/linux-df-command 19/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

Open Security
hybrid
The latest on
cloud
how we reduce
Explore how risks across
we build a environments
more flexible and
future with technologies
Infrastructure
hybrid cloud
The latest on
the world’s
leading
enterprise
Linux platform

https://w w w .redhat.com/en/blog/linux-df-command 20/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

Edge
computing
Updates on
the platforms
that simplify
operations at
the edge

Applications Original
shows
Inside our
solutions to Entertaining
the toughest stories from
the makers
https://w w w .redhat.com/en/blog/linux-df-command 21/24
11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

application and leaders in


challenges enterprise
tech

https://w w w .redhat.com/en/blog/linux-df-command 22/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

https://w w w .redhat.com/en/blog/linux-df-command 23/24


11/21/24, 6:46 PM Check your disk space use w ith the Linux df command

https://w w w .redhat.com/en/blog/linux-df-command 24/24

You might also like