I call df, or disk free, the misunderstood command because new Linux users often expect it to tell the sizes of directories and files. But it doesn't do that-- it's for displaying useful information on filesystems. When you invoke it with no arguments, it shows free and used space on all mounted filesystems, their partitions, and mountpoints:
$ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sdb1 29222392 19353412 8404256 70% / udev 1982916 4 1982912 1% /dev tmpfs 809892 1072 808820 1% /run none 5120 0 5120 0% /run/lock none 2024724 1388 2023336 1% /run/shm /dev/sdb3 593262544 200333868 363234532 36% /home/carla/moarstuff /dev/sda1 1730404792 1616359192 27442000 99% /home/carla/storage /dev/sda2 221176480 160279584 49824796 77% /home/carla/1home
Firecracker the dog is fascinated by Linux filesystems
Add the -h switch for human-readable format, and get rid of the virtual filesystems that exist only in memory, and display just the partitions on your hard drives with grep:
$ df -h |grep ^/ /dev/sdb1 28G 19G 8.1G 70% / /dev/sdb3 566G 192G 347G 36% /home/carla/moarstuff /dev/sda1 1.7T 1.6T 27G 99% /home/carla/storage /dev/sda2 211G 153G 48G 77% /home/carla/1home
df does not operate on individual files or directories, but only filesystems. If you give it a file or directory name as an argument, it gives information for the filesystem the file is on:
$ df -h /var Filesystem Size Used Avail Use% Mounted on /dev/sdb1 28G 19G 8.1G 70% /
I like it for quickly finding out which partitions files are on. It identifies the filesystem types with the -T option:
$ df -Th |grep ^/ /dev/sdb1 ext4 28G 19G 8.1G 70% / /dev/sdb3 ext3 566G 192G 347G 36% /home/carla/moarstuff /dev/sda1 btrfs 1.7T 1.6T 27G 99% /home/carla/storage /dev/sda2 ext4 211G 153G 48G 77% /home/carla/1home
And you can hunt down specific filesystem types:
$ df -ht btrfs /dev/sda1 btrfs 1.7T 1.6T 27G 99% /home/carla/storage
Consult man df and man grep to learn more about what these excellent commands can do. Both are non-destructive commands that only read information, so you can experiment safely.



Exclusive 


Comments
Subscribe to Comments FeedSkatox Said:
Interesting, i alway's though it was free space nor filesystem's free space.
Tanmay Said:
Nice, thanks for the article. I would always remember now its filesystem space info...
Chris Said:
I also like using df -i to display available inodes. Very useful if you're running a squid server.
Terry Said:
For btrfs, you should NOT trust df. Use btrfs filesystem df mount_point instead.
Vasco Said:
Thanks ! please seed more.
someguy Said:
"new Linux users often expect it (df) to tell the sizes of directories and files" And then you show them du? How about a follow up article on du?
David "Barahon" Willson Said:
+1
Steve Said:
tried this before and didn't see my message post... Here are a couple of variations with the primary purpose of including the column headers in the output. These are best used in scripts or aliased (to save typing and typos). df -Th | head -1 ; df -Th | grep ^/ Which works fine with a non-LVM setup. I have one server were I use LVM and ext3 so I modified the command to: df -Th | head -1 ; df -Th | egrep '(^/|ext3)'
fstephens Said:
I use this alias: alias df='df -hT | \egrep -i "file|^/"' Shows a header about the columns.
Steve Said:
I actually had white space in my previous comment that made it a lot easier to read... sorry.
Steve Said:
@fstephens that is much better... I almost always do it the hard way. Thanks!
FtMan Said:
thx,nice
Edmundo Said:
For those trying to find out how much room is taken up by a _directory_, du -s o -sh will do the trick (only that it can take a while if the directlory has a lot of items inside): $ time du -sh ~/Descargas/10.04/ 77G /home/antoranz/Descargas/10.04/ real 2m27.323s user 0m0.284s sys 0m1.828s
Liz Quilty Said:
I find the du command is better at drilling down directories or files which may be using more space (or finding out how big they are for anyone wanting to find that out.
Andrzej Said:
Very helpful! Thanks very much!!
dashesy Said:
Since cgroups are mount points (and there are many of them with long names), df is better for what "mount" could be used before