Command line tips - seeing how much disk space is left with df

It's time for another command line tip today - and that is how to see how much disk space you have left overall on a particular partition.

It's always good to know how much space you have left, especially when you're about to leap into a backup, wget a big file or do some other process which needs a lot of space.

For this reason, there's a great little command called df. Run it on its own and it will show you how many 1 kilobyte blocks are available, are used and how many overall can fit into your partitions. On my system, this gives:

$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/hda8 18844840 10474876 7397232 59% /
tmpfs 516436 0 516436 0% /dev/shm
/dev/hda7 14112620 10267796 3127928 77% /home
/dev/hda1 26627704 11543388 15084316 44% /windows/C
/dev/hdb1 31728896 21759680 9969216 69% /windows/D
/dev/hdb6 16386268 13978836 2407432 86% /windows/E

While this is good, I usually find it much more useful to have the output in a human-readable format. For this reason, you can give df the -h switch and it will do just that (by displaying the number of megabytes or gigabytes instead).

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda8 18G 10G 7.1G 59% /
tmpfs 505M 0 505M 0% /dev/shm
/dev/hda7 14G 9.8G 3.0G 77% /home
/dev/hda1 26G 12G 15G 44% /windows/C
/dev/hdb1 31G 21G 9.6G 69% /windows/D
/dev/hdb6 16G 14G 2.3G 86% /windows/E

And if you ever start getting strange errors and 'No space left on device', it might be a good idea to check df (and then start frantically moving and deleting files). I have had that happen to me before. :)

Avatar for peter Peter Upfold - http://peter.upfold.org.uk/

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Command line tips - seeing how much disk space is left with df

Home » Articles » Command line tips - seeing how much disk space is left with df