Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
 Post subject: disk space
PostPosted: Mon Jan 26, 2004 4:36 pm 
Offline
Senior Newbie

Joined: Tue Sep 16, 2003 11:05 am
Posts: 17
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?


Top
   
 Post subject:
PostPosted: Mon Jan 26, 2004 4:43 pm 
Offline
Senior Member
User avatar

Joined: Mon Jun 23, 2003 1:25 pm
Posts: 260
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


Top
   
 Post subject: Re: disk space
PostPosted: Mon Jan 26, 2004 4:44 pm 
Offline
Senior Member

Joined: Thu Aug 28, 2003 12:57 am
Posts: 273
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.


Top
   
 Post subject:
PostPosted: Mon Jan 26, 2004 5:13 pm 
Offline
Linode Staff
User avatar

Joined: Tue Apr 15, 2003 6:24 pm
Posts: 3090
Website: http://www.linode.com/
Location: Galloway, NJ
I often use this for getting the size of a particular directory:

Code:
du -sh /var/log/

-Chris


Top
   
 Post subject:
PostPosted: Tue Jan 27, 2004 10:41 am 
Offline
Senior Member
User avatar

Joined: Sun Nov 23, 2003 1:40 pm
Posts: 79
Website: http://www.whitehouse.gov/history/presidents/bc42.html
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


Top
   
 Post subject:
PostPosted: Wed Jan 28, 2004 4:45 pm 
Offline
Senior Newbie
User avatar

Joined: Tue Dec 23, 2003 4:37 am
Posts: 8
Website: http://www.inthetour.com
Another way is do this from / as root:

du --max-depth=1 (or however much detail you want)


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group