Linode.com Forum Forum Index Linode.com Forum
Linode Community Forums
 


disk space

Click here to go to the original topic

 
       Linode.com Forum Forum Index -> General Discussion
Author Message
mgeorge



Joined: 16 Sep 2003
Posts: 17

Posted: Mon Jan 26, 2004 3:36 pm    Post subject: disk space  

Being relatively new to some aspects of Linux, what is the easiest way to determine what areas of my filesystem are taking up the most space?
Back to top  
adamgent



Joined: 23 Jun 2003
Posts: 261

Posted: Mon Jan 26, 2004 3:43 pm    Post subject:  

Hi,

To see total usage you can use

df -h

To see how much space each directory and it's subdirectories it taking up you need to cd into the dir and then run

du -h

Adam
Back to top  
bji



Joined: 27 Aug 2003
Posts: 182

Posted: Mon Jan 26, 2004 3:44 pm    Post subject: Re: disk space  

mgeorge wrote: Being relatively new to some aspects of Linux, what is the easiest way to determine what areas of my filesystem are taking up the most space?

I do the following, as root:

Code:
du / 2>&1 | tee /tmp/du.out


That command writes an entry for every directory on the filesystem indicating its size (in kilobytes). Then I view the results with:

Code:
sort -nr /tmp/du.out | less


This sorts the list so that the "biggest" directories are show first. Note that the size indicates the size of the directory and all of its subdirectories. So a big /usr doesn't necessary mean that much, you have to drill down a little bit to figure out what directories are really using the most space unnecessarily.
Back to top  
caker



Joined: 15 Apr 2003
Posts: 2392
Location: Galloway, NJ

Posted: Mon Jan 26, 2004 4:13 pm    Post subject:  

I often use this for getting the size of a particular directory:

Code: du -sh /var/log/
-Chris
Back to top  
Bill Clinton



Joined: 23 Nov 2003
Posts: 79

Posted: Tue Jan 27, 2004 9:41 am    Post subject:  

If you want the amount of space *per* directory and NOT the size of the its subdirectories
Code: du  -Sh  $dir

The following is some example output (to get an idea of what I'm talking about)
Code: sunny@atticus[~]$ du -Sh /var/log/
80K     /var/log/cron
460K    /var/log/cups
516K    /var/log/daemons
664K    /var/log/kernel
68K     /var/log/lpr
380K    /var/log/mail
68K     /var/log/news
8.0K    /var/log/samba
5.4M    /var/log/security
2.6M    /var/log

this helps greatly when needing to locate that specific directory that is eating up your hard disk space

Bill Clinton
Back to top  
mark100net



Joined: 23 Dec 2003
Posts: 6

Posted: Wed Jan 28, 2004 3:45 pm    Post subject:  

Another way is do this from / as root:

du --max-depth=1 (or however much detail you want)
Back to top  
 
       Linode.com Forum Forum Index -> General Discussion
Page 1 of 1