May the source be with you, but remember the KISS principle ;-)

Contents Bulletin Scripting in shell and Perl Network troubleshooting History Humor

df Command

News Classic Unix Utilities Recommended books Recommended Links Filesystem free space monitoring


du df equivalents in Perl Admin Horror Stories Unix History Humor


The df command show the amount of disk space that is free on mounted file systems.  This default action is to display used and free file space in blocks for all mounted filesystems.  If you supply a single partition you will get information on this partition only. Perl has Filesys::Df   module which is an outdated junk -- don't use it.  See df equivalents in Perl

df -P | column -t # Annoyed by wrapped lines in df output. Try -P to unwrap the lines and piping to column will align the columns.


The first column content is different for local and non-local filesystems

Subsequent columns show total space, blocks allocated and blocks available. The capacity column indicates the amount used as a percentage of total file system capacity.

The final column show the mount point of the file system. This is the directory where the file system is mounted within the file system tree.  Other file systems can be mounted in any directory of a previously mounted file system. 

When used in scripts it is typically invoked with option -P.  Unfortunately not all Unix flavors support this option so you need to jump through the hoops if you want you script to be portable:

The most important options

-P, --portability Use a standard, portable, output format (not supported by HP-UX 11 (all versions) and Solaris 9)
The output with -P shall consist of one line of information for each specified file system. These lines shall be formatted as follows:
<fs name>, <total space>, <space used>, <space free>, <percentage used>, <fs root>

The fields are:

<fs name>

The name of the file system, in an implementation-defined format.

<total space>

The total size of the file system in 512-byte units. The exact meaning of this figure is implementation-defined, but should include <space used>, <space free>, plus any space reserved by the system not normally available to a user.

<space used>

The total amount of space allocated to existing files in the file system, in 512-byte units.

<space free>

The total amount of space available within the file system for the creation of new files by unprivileged users, in 512-byte units. When this figure is less than or equal to zero, it shall not be possible to create any new files on the file system without first deleting others, unless the process has appropriate privileges. The figure written may be less than zero.

<percentage used>

The percentage of the normally available space that is currently allocated to all files on the file system. This shall be calculated using the fraction:

<space used> / (<space used>+ <space free>)

expressed as a percentage. This percentage may be greater than 100 if <space free> is less than zero. The percentage value shall be expressed as a positive integer, with any fractional result causing it to be rounded to the next highest integer.

<fs root>

The directory below which the file system hierarchy appear

Option -k. Provide output in kilobytes (not supported by UP-UX). In example below the block size is 1024 bytes ( -k option used) as is indicated in the output.:

# df -k
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/cciss/c0d0p3     11904620   3803304   7486832  34% /
                      15331248   9379732   5160172  65% /home
/dev/mapper/vg00-var  15870920    399220  14652500   3% /var
/dev/mapper/vg00-tmp  31741856  25787520   4315936  86% /tmp
/dev/cciss/c0d0p1       497829     29383    442744   7% /boot
tmpfs                 66042700     40496  66002204   1% /dev/shm

Option -i.If df is invoked with the -i option it displays information about inodes rather that file blocks. An inode is a special disk block (hidden file) that contain file attributes. When a file system is created (using the mkfs command), the file system is created with a fixed number of inodes. If all these inodes become used, a file system cannot store any more files even though there may be free disk space. The df -i command can be used to check for such a problem.

Option -l (gnu df only). Option -l or --local limits the listing to local file systems. By default, remote file systems are also listed.

Grepping the interesting filesystems from the output.

Often you need a subset of all filesystems, for example just Oracle file systems.  Common convention is that Oracle filesystems begin with /u0. In this case you need to take into consideration that filesystem is the last field and anchor your regular expression to the end of the line. Otherwise you might get false positives.

For example:  

# df -kP | egrep "/u0$"
/dev/vx/dsk/oradg/u02vol 12582912 8717924 3744252    70%    /u02
/dev/vx/dsk/oradg/u01vol  8796160 5563610 3131556    64%    /u01
/dev/vx/dsk/oradg/u04vol 10035200 1247888 8519534    13%   /u04
/dev/vx/dsk/oradg/u03vol 12582912 2524060 
9744542    21%    /u03

We can use cut, Perl of awk to extract the fourth column, which is the available space in the filesystem.

$ df -kP | egrep "/u0$" | awk '{ print $4 }'

Writing scripts top monitor free space on filesystems

It is actually pretty difficult to create a good script for monitoring free space of filesystems. For some considerations see Filesystem free space monitoring

Here is a simple way too primitive example:


for i in `df -k | grep /u0 `
 # If any filesystem has less than 100k, issue an alert

   freespace=echo $i | awk '{ print $4 }'
   if [ $freespace -lt 100 ]
      mail -s "On server $HOSTNAME filesystem $i has less then 100K of free space ($freespace)" < df -k | grep "/u0"

We can execute this script each 10 minutes from crontab (Linux cron capability to specify increment is used):

# Filesystem free space below 100K alert
1/10 * * * * /home/oracle/check_filesystem_size.ksh > dev/null >&1

Top updates

Softpanorama Switchboard
Softpanorama Search


Old News

[Dec 05, 2013] Disk usage analysis and cleanup tools By Mayank Sharma

01 February 2006 |

The df utility displays the disk space usage on all mounted filesystems. The -T option prints the filesystem type as well. By default, df measures the size in 1K blocks, which could be a little difficult for a desktop user to decipher. Use the -h option to get more understandable output:

$ df -h -T
Filesystem    Type    Size  Used Avail Use% Mounted on
/dev/hda6     ext3     20G  9.3G  9.1G  51% /
/dev/hda7 reiserfs     13G  2.1G   11G  17% /mnt/suse
/dev/sda1     vfat    241M  152M   90M  63% /media/usbdisk

[Mar 14, 2010] A System Monitoring Tool Primer

Checking Disk Performance and Disk Usage

Linux comes with the /sbin/hdparm program that can be used to control IDE or ATAPI hard drives that are common on most PCs. One feature of the hdparm program is to use the -t option to determine the rate at which data is read from the disk into a buffer in memory. For example, here's the result of typing /sbin/hdparm -t /dev/hda on one system:

 Timing buffered disk reads: 178 MB in  3.03 seconds = 58.81 MB/sec
The command requires the IDE drive's device name (/dev/hda for the first hard drive and /dev/hdb for the second hard drive) as an argument. If you have an IDE hard drive, you can try this command to see how fast data is read from your system's disk drive.
To display the space available in the currently mounted file systems, use the df command. If you want a more readable output from df, type the following command:
df -h
Here's a typical output from this command:
Filesystem            Size  Used Avail Use% Mounted on
/dev/hda5             7.1G  3.9G  2.9G  59% /
/dev/hda3              99M   18M   77M  19% /boot
none                  125M     0  125M   0% /dev/shm
/dev/scd0             2.6G  2.6G     0 100% /media/cdrecorder
As As this example shows, the -h option causes the df command to show the sizes in gigabytes (G) and megabytes (M).

To check the disk space being used by a specific directory, use the du command and specify the -h option to view the output in kilobytes (K) and megabytes (M), as shown in the following example:

du -h /var/log

Here's a typical output of that command:

152K    /var/log/cups
4.0K    /var/log/vbox
4.0K    /var/log/httpd
508K    /var/log/gdm
4.0K    /var/log/samba
8.0K    /var/log/mail
4.0K    /var/log/news/OLD
8.0K    /var/log/news
4.0K    /var/log/squid
2.2M    /var/log
The du command displays the disk space used by each directory, and the last line shows the total disk space used by that directory. If you want to see only the total space used by a directory, use the -s option. For example, type du -sh /home to see the space used by the /home directory. The command produces an output that looks like this:

Recommended Links


GNU df reference

 df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown. Disk space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used.

If an argument is the absolute file name of a disk device node containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node (which is always the root file system). This version of df cannot show the space available on unmounted file systems, because on most kinds of systems doing so requires very nonportable intimate knowledge of file system structures.

GNU df options

Show information about the file system on which each FILE resides, or all file systems by default.

Mandatory arguments to long options are mandatory for short options too.

df reports the amount of disk space used and available on file systems. Synopsis:

     df [option]... [file]...

With no arguments, df reports the space used and available on all currently mounted file systems (of all types). Otherwise, df reports on the file system containing each argument file.

Normally the disk space is printed in units of 1024 bytes, but this can be overridden (see Block size). Non-integer quantities are rounded up to the next higher unit.

If an argument file is a disk device file containing a mounted file system, df shows the space available on that file system rather than on the file system containing the device node (i.e., the root file system). gnu df does not attempt to determine the disk usage on unmounted file systems, because on most kinds of systems doing so requires extremely nonportable intimate knowledge of file system structures.

The program accepts the following options. Also see Common options.

Include in the listing dummy file systems, which are omitted by default. Such file systems are typically special-purpose pseudo-file-systems, such as automounter entries.
‘-B size’
Scale sizes by size before printing them (see Block size). For example, -BG prints sizes in units of 1,073,741,824 bytes.
Print a grand total of all arguments after all arguments have been processed. This can be used to find out the total disk size, usage and available space of all listed devices.
Append a size letter to each size, such as ‘M’ for mebibytes. Powers of 1024 are used, not 1000; ‘M’ stands for 1,048,576 bytes. This option is equivalent to --block-size=human-readable. Use the --si option if you prefer powers of 1000.
Equivalent to --si.
List inode usage information instead of block usage. An inode (short for index node) contains information about a file such as its owner, permissions, timestamps, and location on the disk.
Print sizes in 1024-byte blocks, overriding the default block size (see Block size). This option is equivalent to --block-size=1K.
Limit the listing to local file systems. By default, remote file systems are also listed.
Do not invoke the sync system call before getting any usage data. This may make df run significantly faster on systems with many disks, but on some systems (notably SunOS) the results may be slightly out of date. This is the default.
Use the POSIX output format. This is like the default format except for the following:
  1. The information about each file system is always printed on exactly one line; a mount device is never put on a line by itself. This means that if the mount device name is more than 20 characters long (e.g., for some network mounts), the columns are misaligned.
  2. The labels in the header output line are changed to conform to POSIX.
  3. The default block size and output format are unaffected by the DF_BLOCK_SIZE, BLOCK_SIZE and BLOCKSIZE environment variables. However, the default block size is still affected by POSIXLY_CORRECT: it is 512 if POSIXLY_CORRECT is set, 1024 otherwise. See Block size.
Append an SI-style abbreviation to each size, such as ‘M’ for megabytes. Powers of 1000 are used, not 1024; ‘M’ stands for 1,000,000 bytes. This option is equivalent to --block-size=si. Use the -h or --human-readable option if you prefer powers of 1024.
Invoke the sync system call before getting any usage data. On some systems (notably SunOS), doing this yields more up to date results, but in general this option makes df much slower, especially when there are many or very busy file systems.
‘-t fstype’
Limit the listing to file systems of type fstype. Multiple file system types can be specified by giving multiple -t options. By default, nothing is omitted.
Print each file system's type. The types printed here are the same ones you can include or exclude with -t and -x. The particular types printed are whatever is supported by the system. Here are some of the common names (this list is certainly not exhaustive):
An NFS file system, i.e., one mounted over a network from another machine. This is the one type name which seems to be used uniformly by all systems.
‘4.2, ufs, efs...’
A file system on a locally-mounted hard disk. (The system might even support more than one type here; Linux does.)
‘hsfs, cdfs’
A file system on a CD-ROM drive. HP-UX uses ‘cdfs’, most other systems use ‘hsfs’ (‘hs’ for “High Sierra”).
An MS-DOS file system, usually on a diskette.


‘-x fstype’
Limit the listing to file systems not of type fstype. Multiple file system types can be eliminated by giving multiple -x options. By default, no file system types are omitted.
Ignored; for compatibility with System V versions of df.

An exit status of zero indicates success, and a nonzero value indicates failure. Failure includes the case where no output is generated, so you can inspect the exit status of a command like ‘df -t ext3 -t reiserfs dir’ to test whether dir is on a file system of type ‘ext3’ or ‘reiserfs’.


FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available in our efforts to advance understanding of environmental, political, human rights, economic, democracy, scientific, and social justice issues, etc. We believe this constitutes a 'fair use' of any such copyrighted material as provided for in section 107 of the US Copyright Law. In accordance with Title 17 U.S.C. Section 107, the material on this site is distributed without profit exclusivly for research and educational purposes.   If you wish to use copyrighted material from this site for purposes of your own that go beyond 'fair use', you must obtain permission from the copyright owner. 

ABUSE: IPs or network segments from which we detect a stream of probes might be blocked for no less then 90 days. Multiple types of probes increase this period.  


Groupthink : Two Party System as Polyarchy : Corruption of Regulators : Bureaucracies : Understanding Micromanagers and Control Freaks : Toxic Managers :   Harvard Mafia : Diplomatic Communication : Surviving a Bad Performance Review : Insufficient Retirement Funds as Immanent Problem of Neoliberal Regime : PseudoScience : Who Rules America : Neoliberalism  : The Iron Law of Oligarchy : Libertarian Philosophy


War and Peace : Skeptical Finance : John Kenneth Galbraith :Talleyrand : Oscar Wilde : Otto Von Bismarck : Keynes : George Carlin : Skeptics : Propaganda  : SE quotes : Language Design and Programming Quotes : Random IT-related quotesSomerset Maugham : Marcus Aurelius : Kurt Vonnegut : Eric Hoffer : Winston Churchill : Napoleon Bonaparte : Ambrose BierceBernard Shaw : Mark Twain Quotes


Vol 25, No.12 (December, 2013) Rational Fools vs. Efficient Crooks The efficient markets hypothesis : Political Skeptic Bulletin, 2013 : Unemployment Bulletin, 2010 :  Vol 23, No.10 (October, 2011) An observation about corporate security departments : Slightly Skeptical Euromaydan Chronicles, June 2014 : Greenspan legacy bulletin, 2008 : Vol 25, No.10 (October, 2013) Cryptolocker Trojan (Win32/Crilock.A) : Vol 25, No.08 (August, 2013) Cloud providers as intelligence collection hubs : Financial Humor Bulletin, 2010 : Inequality Bulletin, 2009 : Financial Humor Bulletin, 2008 : Copyleft Problems Bulletin, 2004 : Financial Humor Bulletin, 2011 : Energy Bulletin, 2010 : Malware Protection Bulletin, 2010 : Vol 26, No.1 (January, 2013) Object-Oriented Cult : Political Skeptic Bulletin, 2011 : Vol 23, No.11 (November, 2011) Softpanorama classification of sysadmin horror stories : Vol 25, No.05 (May, 2013) Corporate bullshit as a communication method  : Vol 25, No.06 (June, 2013) A Note on the Relationship of Brooks Law and Conway Law


Fifty glorious years (1950-2000): the triumph of the US computer engineering : Donald Knuth : TAoCP and its Influence of Computer Science : Richard Stallman : Linus Torvalds  : Larry Wall  : John K. Ousterhout : CTSS : Multix OS Unix History : Unix shell history : VI editor : History of pipes concept : Solaris : MS DOSProgramming Languages History : PL/1 : Simula 67 : C : History of GCC developmentScripting Languages : Perl history   : OS History : Mail : DNS : SSH : CPU Instruction Sets : SPARC systems 1987-2006 : Norton Commander : Norton Utilities : Norton Ghost : Frontpage history : Malware Defense History : GNU Screen : OSS early history

Classic books:

The Peter Principle : Parkinson Law : 1984 : The Mythical Man-MonthHow to Solve It by George Polya : The Art of Computer Programming : The Elements of Programming Style : The Unix Hater’s Handbook : The Jargon file : The True Believer : Programming Pearls : The Good Soldier Svejk : The Power Elite

Most popular humor pages:

Manifest of the Softpanorama IT Slacker Society : Ten Commandments of the IT Slackers Society : Computer Humor Collection : BSD Logo Story : The Cuckoo's Egg : IT Slang : C++ Humor : ARE YOU A BBS ADDICT? : The Perl Purity Test : Object oriented programmers of all nations : Financial Humor : Financial Humor Bulletin, 2008 : Financial Humor Bulletin, 2010 : The Most Comprehensive Collection of Editor-related Humor : Programming Language Humor : Goldman Sachs related humor : Greenspan humor : C Humor : Scripting Humor : Real Programmers Humor : Web Humor : GPL-related Humor : OFM Humor : Politically Incorrect Humor : IDS Humor : "Linux Sucks" Humor : Russian Musical Humor : Best Russian Programmer Humor : Microsoft plans to buy Catholic Church : Richard Stallman Related Humor : Admin Humor : Perl-related Humor : Linus Torvalds Related humor : PseudoScience Related Humor : Networking Humor : Shell Humor : Financial Humor Bulletin, 2011 : Financial Humor Bulletin, 2012 : Financial Humor Bulletin, 2013 : Java Humor : Software Engineering Humor : Sun Solaris Related Humor : Education Humor : IBM Humor : Assembler-related Humor : VIM Humor : Computer Viruses Humor : Bright tomorrow is rescheduled to a day after tomorrow : Classic Computer Humor

The Last but not Least

Copyright ฉ 1996-2016 by Dr. Nikolai Bezroukov. was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. This document is an industrial compilation designed and created exclusively for educational use and is distributed under the Softpanorama Content License.

The site uses AdSense so you need to be aware of Google privacy policy. You you do not want to be tracked by Google please disable Javascript for this site. This site is perfectly usable without Javascript.

Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

FAIR USE NOTICE This site contains copyrighted material the use of which has not always been specifically authorized by the copyright owner. We are making such material available to advance understanding of computer science, IT technology, economic, scientific, and social issues. We believe this constitutes a 'fair use' of any such copyrighted material as provided by section 107 of the US Copyright Law according to which such material can be distributed without profit exclusively for research and educational purposes.

This is a Spartan WHYFF (We Help You For Free) site written by people for whom English is not a native language. Grammar and spelling errors should be expected. The site contain some broken links as it develops like a living tree...

You can use PayPal to make a contribution, supporting development of this site and speed up access. In case is down you can use the at


The statements, views and opinions presented on this web page are those of the author (or referenced source) and are not endorsed by, nor do they necessarily reflect, the opinions of the author present and former employers, SDNP or any other organization the author may be associated with. We do not warrant the correctness of the information provided or its fitness for any purpose.

Last modified: June 06, 2016