My hard drive became full. I am looking for ways to locate the things that use most of my disk space. I played with cron once so it may have consumed a great deal of space, but really I have no clue.

I have backed up my things to CDs, but the system is still getting too slow. Perhaps I should reinstall everything, but whilst fixing the problem it doesn't address the cause.

What is the easiest way to free space on a hard drive?

link|improve this question

1. You should really specify the OS for which you are looking tools and suggestions. (though seeing your username might be enough of an answer :-)) 2. I have the sneaky suspicion that this question will be closed as "Not programming related"... – Franci Penov Feb 14 '09 at 6:01
I am using Ubuntu as a VM on mac. – Masi Feb 14 '09 at 6:49
feedback

migrated from stackoverflow.com Feb 26 '10 at 14:26

This question came from our site for professional and enthusiast programmers.

10 Answers

up vote 5 down vote accepted

"I played with cron once so it may have consumed my mass memory, but really I have no clue."

No clue, you say? never would have guessed. :)

su -
cd /
du -s ./* | sort -n

"du" shows disk usage, in blocks (1 block = 0.5 kilobytes, in all cases that matter to you.)

-s means, "summary", so it gives only a total for each argument "./*" being the argument.

piping it into sort -n means sort numerically. The larger numbers at the bottom.

So, you'll get a list of directories with the ones using the most space at the bottom.

If that's not enough help, say you get:

60380   ./root
142468  ./etc
537716  ./var
627264  ./lib
5757600 ./usr
28859472        ./home

and you see that ./home is the biggest piggy, ok, cd into /home, and do the same "du -s | sort -n" Then you see who in /home is taking up space. (on a single user system, well, it's probably you.)

Then cd into there, and do "du -s | sort -n" again.

Keep doing this until you find the culprit. When you find the culprit, you may say, oh yeah... that's my collection of hi-res renderings of Romulan Birds of Prey for my star trek RPG game that I'm building, so yeah, of course that takes up a lot of space, or you may say, of course that takes up a lot of space, so let's rm -fr that bad boy.

Magic words to remember:

du -s | sort -n
link|improve this answer
feedback

Check out the Disk Usage Analyzer, you can find it in Programs -> Accessories, it will analyze the disk usage and show it as a diagram to you.

Also, remove unnecessary programs and clear out the old package cache by running sudo apt-get clean .

link|improve this answer
feedback

rm -rf ~/porn

link|improve this answer
Funny, but not very useful. – EndangeredMassa Feb 14 '09 at 6:11
Unless "du -s ~" shows porn as the big filesystem user :-) – paxdiablo Feb 14 '09 at 6:33
It's funny because it's true. – njd Feb 26 '10 at 15:08
feedback

KDirStat is another option which will help you identify large files and directories.

alt text

I've used the Windows clone WinDirStat a lot and it is an awesome tool.

link|improve this answer
feedback

I had the same problem recently and I had good results with CCleaner - it found almost 8GB of deletable files that were missed by Windows' built in disk cleaner and a couple other utilities I tried. (This on a 20GB partition)

EDIT: See, that's why you need to specify the operating system, as mentioned in the comment... I don't know of any equivalent to CCleaner for Uix/Linux, but have a look in the temporary directories like /tmp, /var/tmp, and $HOME/tmp. Unneeded files sometimes accumulate there.

link|improve this answer
I would have thought the OS would have been obvious from the "cron" comment, but maybe Windows aficionados aren't as familiar with UNIX tools. – paxdiablo Feb 14 '09 at 6:32
well in theory, there are cron varients for windows... – Journeyman Geek Feb 26 '10 at 14:32
Indeed, cron the concept is cross-platform (and I will state for the record that I am a Linux user, and have never been a "Windows aficionado") – David Zaslavsky Mar 20 '10 at 20:40
feedback

CCleaner can help you save a few gigs. Cleans all the temporary files.

TreeSize Free to locate big files. Same for JDiskReport.

link|improve this answer
feedback

Per the "Linux Server Hacks" by O'Reilly

alias ducks='du -cks * | sort -rn | head -11'

Then go to any directory and run the alias

link|improve this answer
feedback

To expand on Bobby's last point, run
sudo apt-get autoremove
sudo apt-get autoclean

to clear out all extra packages and unneeded install files. Also, it would be a really good idea to go through your applications and remove the ones you don't use any more.

link|improve this answer
feedback

Check out DiskView. It allows you to visualize the items on your drive and easily identify items which are taking a lot of space.

You also might consider simply upgrading to a bigger drive.

link|improve this answer
feedback

TreeSize is the tool of my choice in those cases.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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