Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to calculate the size of my home directory, which has a lot of sub directories.

It takes about 40 seconds to run du.
Is there a quicker way?

$ time du -sh
5.0G    .

real    0m39.676s
user    0m0.058s
sys     0m3.151s
share|improve this question

3 Answers 3

up vote 2 down vote accepted

A rather round about method would be to put your home directory on a separate partition that gets mounted at boot, making sure it is large enough for all your future needs.

After you've done that then the fastest way to tell how much space you are using is the df command which will show the free and used space on the partitions. df also has switches to show the information in human readable formats.

share|improve this answer
    
Advantage compared to what? du doesn't count multiply hardlinked files more than once, either. This is required by the SUS. (GNU du has a --count-links option that turns this behaviour off and causes multiply linked files to be counted multiple times.) –  JdeBP Nov 29 '11 at 13:37
    
@JdeBP Nice, didn't expect that. –  Daniel Beck Nov 29 '11 at 14:22
1  
I always set up a separate home partition. If for some reason, my installation hates me, all my stuff is right there still, no digging around. It's pretty easy to move to using a new partition instead of all one partition, too. –  Rob Nov 29 '11 at 14:23
    
As a side point (related to @Robs comment), separate home partitions can make to upgrade to new or different distributions without having to worry about your personal data being wiped in the process, and can make it a lot easier to share data if you are dual booting multiple OS'es. –  Mokubai Nov 29 '11 at 15:06

… or, thirdly, one can use disc quotas.

A variant on Mokubai's roundabout answer is to have all home directories on a dedicated volume for home directories, to enable disc quotas on that volume (and build the quota database if quotas are being added to a volume with data already on it), and to use the quota command to display how much of a user's disc quota for that volume that user has used. Those used to traditional Unices in centralized multi-user timesharing environments will find this very familiar. ☺

This really does have an advantage over du when it comes to the "How much disc space is the stuff that I own taking up?" question: If some other user slyly hardlinks one of your files — that you subsequently unlink from your home directory and think to be gone — into one of xyr own directories, that xe denies you read+execute permission for (and that hence you cannot scan with du), the disc space that it consumes will still count against your disc quota and you can detect the discrepancy.

And, of course, all the security and maintainability advantages of having a separate volume for all home directories also apply.

share|improve this answer

No, there isn't a quick way. You need to go through all subdirectories.

share|improve this answer
    
It would be possible using a service similar to indexed desktop search. –  Daniel Beck Nov 29 '11 at 10:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.