3

Possible Duplicate:
How can I determine what is taking up so much space?

I just had an old server go belly up because it ran out of drive space. I am logged in to the shell, and I'm trying to find more unused files to remove.

Is there shell a command, script, or app that will display the largest files/folders?

MrGlass
  • 131
  • 1
  • 1
  • 4

4 Answers4

8

This command will help you find big directories 5 levels deep. It also orders the directories by the size.

I had a similar problem long time ago where apache sessions where filling my disk and slowing down my web server.

du --max-depth=5 /* | sort -rn
user9517
  • 114,104
  • 20
  • 206
  • 289
Hex
  • 1,939
  • 10
  • 17
4

The largest top 10 files and directories with size in a human-readable format:

du -shx /* | sort -rh | head
quanta
  • 50,327
  • 19
  • 152
  • 213
  • Perfect. And then you can drill down into subdirectories by modifying the command, ie, `du -shx /var/* | sort -rh | head` where "var" is the subdirectory you want to investigate. I used this a few levels deep until I found the individual file that was causing issues. – bboyle1234 Apr 22 '20 at 05:11
2

You can use

du -h --max-depth=1 /

and then work your way down the filesystem till you find it.

If it's a long running system, the chances are high that it's a log file that has filled the disk. If that's the case then make sure you shutdown the process that's writing to it before archiving/deleting it as just deleting often doesn't recover the disk space.

user9517
  • 114,104
  • 20
  • 206
  • 289
2

The du command will get you this information. For example:

cd /
du -sm *
9   bin
18  boot
1   dev
6   etc
685 export
1   home
...
EEAA
  • 108,414
  • 18
  • 172
  • 242