Why command df and du reports different output?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Why command df and du reports different output?
# 1  
Old 07-04-2008
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
# 2  
Old 07-05-2008
Its like that Smilie
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
# 3  
Old 07-06-2008
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 ...
# 4  
Old 07-06-2008
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?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert title as output of command to appended file if no output from command

I am using UNIX to create a script on our system. I have setup my commands to append their output to an outage file. However, some of the commands return no output and so I would like something to take their place. What I need The following command is placed at the prompt: TICLI... (4 Replies)
Discussion started by: jbrass
4 Replies

2. UNIX for Dummies Questions & Answers

Set Command to output a log of every command executed in the script

Hi Guys, I like to output every command executed in the script to a file. I have tried set -x which does the same. But it is not giving the logs of the child script which is being called from my script. Is there any parameters in the Set command or someother way where i can see the log... (2 Replies)
Discussion started by: mac4rfree
2 Replies

3. Red Hat

Command understanding the output file destination in case of standard output!!!!!

I ran the following command. cat abc.c > abc.c I got message the following message from command cat: cat: abc.c : input file is same as the output file How the command came to know of the destination file name as the command is sending output to standard file. (3 Replies)
Discussion started by: ravisingh
3 Replies

4. Shell Programming and Scripting

Want to terminate command execution when string found in the command output

Hi Experts, I am very much new to linux scripting, I am currently working on reducing my manual work and hence writing a script to automate few task. I am running below command to snmpwalk the router.. snmpwalk -v 3 -u WANDL_SU -a MD5 -A vfipmpls -x DES -X VfIpMpLs -l authPriv... (19 Replies)
Discussion started by: Hanumant.madane
19 Replies

5. Shell Programming and Scripting

Script/command to find the common element from 2 reports

please look the scenario (8 Replies)
Discussion started by: dll_fpga
8 Replies

6. Shell Programming and Scripting

Script/command to find the common element from 2 reports

Please see the below reports.... The startpoint will be always same but the endpoint is different ,across various reports and im looking for a search between "clock network delay(propagated)" and "data arrival time" ....to find the element which is common in both reports(reports are seperated... (0 Replies)
Discussion started by: dll_fpga
0 Replies

7. UNIX for Dummies Questions & Answers

passing command output from one command to the next command in cshell

HI Guys, I hope you are well. I am trying to write a script that gets executed every time i open a shell (cshell). I have two questions about that 1) I need to enter these commands $ echo $DISPLAY $ setenv $DISPLAY output_of_echo_$display_command How can i write a... (2 Replies)
Discussion started by: kaaliakahn
2 Replies

8. UNIX for Advanced & Expert Users

Repeat output of last command w/o repeating last command

Is there a way to repeat the output of the last command for filtering without running the command again? All I could think of was to copy all the data to a text file and process it that way, is there another way? Like say I want to grep server.server.lan from a dtrace that was pages long after I... (5 Replies)
Discussion started by: glev2005
5 Replies

9. UNIX for Dummies Questions & Answers

Command display output on console and simultaneously save the command and its output

Hi folks, Please advise which command/command line shall I run; 1) to display the command and its output on console 2) simultaneous to save the command and its output on a file I tried tee command as follows; $ ps aux | grep mysql | tee /path/to/output.txt It displayed the... (7 Replies)
Discussion started by: satimis
7 Replies

10. UNIX for Dummies Questions & Answers

problem with output of find command being input to basename command...

Hi, I am triying to make sure that there exists only one file with the pattern abc* in path /path/. This directory is having many huge files. If there is only one file then I have to take its complete name only to use furter in my script. I am planning to do like this: if ; then... (2 Replies)
Discussion started by: new_learner
2 Replies
Login or Register to Ask a Question