Debarshi's den - দেবর্ষির ডেড়া

Debarshi's posts with tag: du

What are tags? You can give your posts a "tag", which is like a keyword. Tags help you find content which has something in common. You can assign as many tags as you wish to each post.
View posts by people in your network with tag du
Blog EntryWhat is the size?Aug 13, '06 1:06 AM
for everyone
Finding the size of a directory was one of the things I could not figure out how to do from the terminal. I recall someone saying that one would require sed and gawk to do it. That terrified me...

So here is the simple way to do it.

[rishi@Sunflower ~]$ du -sh /data
4.8G /data
[alien@Sunflower ~]$ du -sh .
20M .

However it becomes quite slow if one wants to check the size of something as big as /. This is because the cumulative sum of all the files and folders are actually found during run-time to find the size. The following command took me almost 5 minutes.

[rishi@Sunflower ~]$ sudo du -sh /
18G /

Doesn't the ext3 filesystem store the sizes of directories somewhere permanently? If not, then how come df is so fast? The following does not take even a second to execute.

[rishi@Sunflower ~]$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/hda2 18G 11G 6.0G 64% /
/dev/hda1 92M 19M 68M 22% /boot
/dev/hda3 6.0G 4.8G 845M 86% /data
tmpfs 109M 0 109M 0% /dev/shm
/dev/hda7 221M 49M 161M 24% /devel
/dev/hda5 2.0G 1.7G 222M 89% /home
/dev/hda6 996M 34M 911M 4% /tmp

These are the questions I need to find answer to now...

© 2008 Multiply, Inc.    About · Blog · Terms · Privacy · Corp Info · Contact Us · Help