LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-09-2012, 02:40 PM   #1
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Rep: Reputation: 15
du doesn't add up?


When I change to my website directory and run

Code:
du BKM/
I get the following output:
Code:
chaz@optimus:~/docs/tiWobs$ du BKM/
//a bunch of files and subdirectories
28352	BKM/
chaz@optimus:~/docs/tiWobs$

However when I paste this output into a spreadsheet, and add up all the sizes (leaving out the last line of course) I get some 54k and not 28k. Why the discrepancy? Which one is right?
 
Old 01-09-2012, 04:17 PM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Try the "human" option to du:
Code:
du -hs dir
will only show a summary (in bytes, megabytes, gigabytes, etc.). Without an argument, du reports in blocks (see the manual page).

Hope this helps some.
 
Old 01-09-2012, 04:31 PM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
to add to the above answer

Without the -s option, du will report the disk usage for every file AND FOLDER below the current level (default), or the parameters on the command line.

Since it reports the space a file takes, then also reports that space as part of the space taken by the folder HOLDING that file, the total of all those lines will ALWAYS add to more than the total space actually used. Adding the -s makes it report space used ONLY by the (s)ingle entities listed as parameters (or the current folder if you provide no parameters).

If the man page does not make it clear, there are online documents that describe these commands and options in finer detail. (Or, you can ask here.)
 
Old 01-09-2012, 04:35 PM   #4
Daravon
Member
 
Registered: Mar 2006
Posts: 170

Original Poster
Rep: Reputation: 15
Quote:
Since it reports the space a file takes, then also reports that space as part of the space taken by the folder HOLDING that file, the total of all those lines will ALWAYS add to more than the total space actually used.
Oh wow. Of course. I'm glad I asked this in the newbie forum...

Last edited by Daravon; 01-09-2012 at 04:47 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] chkconfig --add doesn't let me add x201s Linux - Newbie 2 03-14-2011 09:47 PM
df command output, doesn't add up? jrfk2 Linux - Newbie 5 07-13-2006 07:16 AM
add route doesn't work tkt Linux - Newbie 1 06-29-2005 05:56 PM
gMPlayer doesn't list the right vo drivers; how can I add them? DaneM Linux - Software 3 01-19-2005 06:28 AM
Why doesn't make install add a shortcut? Pontius Linux - Software 3 05-19-2004 04:59 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 11:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration