The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
Google UNIX.COM


UNIX for Advanced & Expert Users Advanced UNIX and Linux questions go here. Expert-to-Expert.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Dig command output? sujathab UNIX for Dummies Questions & Answers 1 01-21-2008 06:54 AM
output of who command sanjaykhuntia Linux 1 10-31-2007 05:35 AM
if command not having the right output filthymonk Shell Programming and Scripting 9 05-22-2007 10:11 PM
Output of ps -ef command dbrundrett UNIX for Advanced & Expert Users 6 01-06-2005 11:48 AM
Output command berty007 Shell Programming and Scripting 4 11-29-2002 02:27 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 07-04-2008
Registered User
 

Join Date: Mar 2007
Posts: 57
Why command df and du reports different output?

There a mismatch between df and du outputs
Both df and du reporting different output. It is confusing.
the answer that I get is that Open file descriptor is main causes of such wrong information.
For example if file is open by third party application OR by a user and same file is deleted,
both df and du reports different output.
Is any way to fix/bypass this ?

p.s
Usually this scenario is happening on Linux RH
Reply With Quote
Forum Sponsor
  #2  
Old 07-05-2008
Registered User
 

Join Date: May 2008
Location: s'pore
Posts: 916
Its like that
The df, du, and ls commands have a new h option for displaying disk usage and file or file system sizes that are easy to understand.

The default form of the df command displays file system size in blocks (512 bytes). The df output, in kilobytes, follows:



$ df -k / /usr
Filesystem kbytes used avail capacity Mounted on
/dev/dsk/c0t0d0s0 192056 94788 78063 55% /
/dev/dsk/c0t0d0s6 1982988 829966 1093533 44% /usr

The same file system sizes displayed in powers of 1024 follows:



$ df -h / /usr
Filesystem size used avail capacity Mounted on
/dev/dsk/c0t0d0s0 188M 93M 76M 55% /
/dev/dsk/c0t0d0s6 1.9G 811M 1.0G 44% /usr

The default form of the du command displays disk space in blocks (512 bytes). The du output, in blocks, follows:



% du -s k*
100 kadmin
98 kadmin.local
98 kdb5_util
90 keyserv
10 killall

The same disk space displayed in powers of 1024 follows:



% du -h k*
50K kadmin
49K kadmin.local
49K kdb5_util
45K keyserv
5K killall

The default form of the ls -l command displays file size in bytes. Use the ls -lh command to display file size in powers of 1024:



% ls -lh k
-r-xr-xr-x 1 root bin 49K Nov 30 03:32 kadmin
-r-xr-xr-x 1 root bin 49K Nov 30 03:32 kadmin.local
-r-xr-xr-x 1 root bin 49K Nov 30 03:32 kdb5_util
-r-xr-xr-x 1 root sys 44K Nov 25 04:37 keyserv
-r-xr-xr-x 1 root bin 4.3K Nov 25 04:36 killall
Reply With Quote
  #3  
Old 07-06-2008
Registered User
 

Join Date: Mar 2007
Posts: 57
this is not the differences that I meant.
I mean that in df -h I see usage of 100G and in du -h I see only 1M ...
Reply With Quote
  #4  
Old 07-06-2008
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,667
du and df are fundamentally different. df reports on a filesystem as a whole, while du reports on individual files. Yes, du cannot see deleted files that are still open. Mostly, those are caused by folks who use the rm command without thinking. The space will be freed when the process exits and a reboot will kill all processes. So a reboot will tend to equalize usage reported by the commands and not rm'ing open files will help stop it from happening in the first place. But not all filesystem space is devoted to files. There is meta-data too...inodes, cylinder groups, super blocks, etc. They will never be the same...and if they were, what would be the point of a duplicate command?
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 02:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0