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?

5 Replies

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

@mgeorge:

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:

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:

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.

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

du -sh /var/log/

-Chris

If you want the amount of space per directory and NOT the size of the its subdirectories

du  -Sh  $dir

The following is some example output (to get an idea of what I'm talking about)

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

Another way is do this from / as root:

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

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct