7 Linux df Command Examples

df command in Linux provides disk space usage information of your file systems. Even if you already know about this command, probably one of the examples mentioned below might be new to you.
A sample output from df command is as follows:

So we see that in the output, details of all the file systems and their memory usage is there.

2. Specify the Memory Block Size

If you see the output in point 1 above, the second column gives the memory of file system in memory blocks of 1k. df command provides an option through which we can change the size of memory block in the output. Use option -B for this:

So you see that we specified a block size of 100 and in the output (second column) block size of 100 is displayed.

3. Print Human Readable Sizes

We are used to reading the memory in terms of gigabytes, megabytes, etc as its easy to read and remember. df command also provides an option ‘-h’ to print the memory statistics in human readable format.

Option -h stands for “human” readable format. As shown in the output below, G is used for gigabytes and M is used for megabytes.

good job. thanks. I appreciate it when you expand out the meaning of the options. For example “df -h” and you explain that -h is for “human readable”. A lot of times we have difficulty remembering the option because we don’t remember what it stands for. Expanding the option helps us remember. This is something to keep in mind for your future columns.

Thanks for pointing out a couple of new flags to add to my df use. I wanted to add one of my top flags as well (-P) which forces POSIX compliant output and makes reading df output when using LVM much easier to read:
df -hP

If you want the output of df shown in a neat table use: df | column -t

To have all partitions sorted by percentage of used disk space (in increasing order) type:
df -Ph | sort -nk5
Options:
-n: sort by entire number not only the first digit, so 5% comes after say 1% and not 12%
-k5: sort using column 5 (in our case percentage of disk space used)

Hi Ramesh,
This is regarding tmpfs query.Kindly find the below details and help on this .

we have server with 7 Gb and Tmpfs is 4 Gb. No process/application is using more memory but we are facing memory issue. And it is not a Db server

Questions :
1) In free -g we have only 3 gb free (buffer+caches is 2 gb and cache is 1 gb). and what about the reaming memory ?
2) configuring tmpfs is good or not in linux server (without DB (oracle) installed on it)
3) If we configured tmpfs ,it will directly took it from physical ram or not ? if yes means, then it will be shown as used in free command or not ?

About The Geek Stuff

My name is Ramesh Natarajan. I will be posting instruction guides, how-to, troubleshooting tips and tricks on Linux, database, hardware, security and web. My focus is to write articles that will either teach you or help you resolve a problem. Read more about Ramesh Natarajan and the blog.

Contact Us

Email Me :
Use this Contact Form to get in touch me with your comments, questions or suggestions about this site. You can also simply drop me a line to say hello!.