Linux Basics: Find The Amount Of Free Disk Space On File Systems With The ‘df’ Utility
In this tutorial I will show you how to use the df command to perform some practical and useful stuff in your own linux machine. You are not going to get a full documentation of this file system disk space usage reporter here but rather some very important skills valuable in the linux world.
Do you like to know the amount of disk space available on a filesystem? I do. Open a new terminal (CTRL+ALT+T In Ubuntu) and run the following command.
As you guys can see we did not call the df utility with any argument, but the information provided by it seems to be very readable and useable for a linux geek.
What information do we get by running the above command? Before going any further make sure to run the command and test it so you can keep up with this tutorial.
Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 476482584 31790184 420481764 8% / udev 1951928 4 1951924 1% /dev tmpfs 785960 860 785100 1% /run none 5120 0 5120 0% /run/lock none 1964892 276 1964616 1% /run/shm /dev/sda1 94759 2099 92660 3% /boot/efi /home/oltjano/.Private 476482584 31790184 420481764 8% /home/oltjano
The information given by the df tool when it is called without any arguments is oraganised in six different columns. We can easily gather stats about the total space available on the file system, used space and free space.
What about the first column? It shows the disk partition as it appears in the /dev directory. Math geeks will be very happy to get the used space percentage.
A thing that really deserves attention and should be explained is the 1K-blocks which is used as the unit measure for expressing the used and free space. The block size is 1024 bytes.
We didn’t say anything about the last column, did we? Are you curious to know something about the information it holds? The final column gives information about the mounting point of each one of the file systems.
Note: The / indicates the root partition.
Now lets make the displayed information available in an easy format so humans can understand it. To do this we need to call df with the h option which will print sizes in a human readable format.
The above command produces the following output.
Filesystem Size Used Avail Use% Mounted on /dev/sda2 455G 31G 402G 8% / udev 1.9G 4.0K 1.9G 1% /dev tmpfs 768M 860K 767M 1% /run none 5.0M 0 5.0M 0% /run/lock none 1.9G 276K 1.9G 1% /run/shm /dev/sda1 93M 2.1M 91M 3% /boot/efi /home/oltjano/.Private 455G 31G 402G 8% /home/oltjano
It is easier to understand and interpret it now, isn’t it? Maybe you are interested in a grant total. The total option can be used to help you with that.
The following is the output of the above command.
Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda2 476482584 31790820 420481128 8% / udev 1951928 4 1951924 1% /dev tmpfs 785960 860 785100 1% /run none 5120 0 5120 0% /run/lock none 1964892 276 1964616 1% /run/shm /dev/sda1 94759 2099 92660 3% /boot/efi /home/oltjano/.Private 476482584 31790820 420481128 8% /home/oltjano total 957767827 63584879 845761676 7%
You can also scale sizes before printing them. According to the man page of the df command, when the utility is invoked with the -BM option it prints sizes in units of 1,048,576 bytes.
And now the last but not least, the -i option. It is used to display information about the inodes that are available on a file system. Each file system has a specified number of inodes.
What does the term inode mean?
As far as I am concerned it is used to represent a file system object.
When asked, Unix pioneer Dennis Ritchie replied:
In truth, I don’t know either. It was just a term that we started to use. “Index” is my best guess, because of the slightly unusual file system structure that stored the access information of files as a flat array on the disk, with all the hierarchical directory information living aside from this. Thus the i-number is an index in this array, the i-node is the selected element of the array. (The “i-” notation was used in the 1st edition manual; its hyphen was gradually dropped.)
Ok, now run the following command and see what is going to happen.
The following is the information that gets displayed in my lovely terminal.
Filesystem Inodes IUsed IFree IUse% Mounted on /dev/sda2 30269440 440465 29828975 2% / udev 487982 513 487469 1% /dev tmpfs 491223 443 490780 1% /run none 491223 3 491220 1% /run/lock none 491223 9 491214 1% /run/shm /dev/sda1 0 0 0 - /boot/efi /home/oltjano/.Private 30269440 440465 29828975 2% /home/oltjano
Go hard in terminal and play hard!
For more information, refer the man pages.
Like us on Facebook
We need your assistance to stay live
This week Top Posts
- Top Things To Do After Installing Ubuntu 13.10 'Saucy Salamander' : Ubuntu 13.10 Saucy Salamander will be released on coming October 17th with many new salient featur...0 comments |
- Fedora 21 Scheduled For Release In October : For Fedora users, just keep calm and use Fedora 20 for now. Fedora Developers has announced that F...1 comment |
- How To Upgrade From Ubuntu 13.04 Raring To Ubuntu 13.10 Saucy Salamander : Ubuntu 13.10 Saucy will be released on October 17th. Hope it will come with lot of improvements and ...0 comments |
- Install LAMP Server (Apache, MySQL or MariaDB, PHP) On Ubuntu 13.10 : Updated January 12, 2014 LAMP is a combination of operating system and open-source software stack. ...0 comments |
- Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comments |
- DNS Server Installation Step by Step Using CentOS 6.5/6.4/6.3 : DNS, Domain Name System, translates hostnames or URLs into IP addresses. For example if we type www....0 comments |
- Fedora 21 Scheduled For Release In October
- Install Uget Download Manager In Ubuntu, Fedora, Debian
- Download Elementary OS ‘Luna’ Official Wallpapers
- Install Power Commands 0.1.5 On Ubuntu 14.04/13.10/12.10/12.04
- 5 Android Apps that’s Going to Make Running Your Business Less Stressful
- Puppet agent Install Using Script
- Install Corosync and Pacemaker On CentOS 6.5
- Install Fail2Ban On Ubuntu Server 13.04/13.10
- How To Install Google Chrome in Fedora 20, 19, 18
- How to surf using Tor Browser Bundle
This work by unixmen.com is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported License.
Copyright © 2008-2013 Unixmen.com .