Bowlero

From Tech stuff to paranormal to internet marketing



How to find the largest files or directories in Linux?

My VPS disk usage is already 96% so I have to find a way to search for the largest files/directories in Linux and check if they should be deleted or not.   I’m sure I can find files such as web log files which I can delete.

There isn’t any 1 linux command to do this but you can string a couple of commands to do the job.  Here’s what I use.
# du -a /home | sort -n -r | head -n 300

  • du : Estimate file space usage
  • sort : Sort lines of text files or given input data
  • head : Output the first part of files i.e. to display first 10 largest file

Better yet, you can run it in your background using this

# du -a /home | sort -n -r | head -n 300 >  spacehog.txt &

This will create a text file called spacehog.txt which you can review later after the background process finished.







2 Responses to 'How to find the largest files or directories in Linux?'

  1. gary - September 8th, 2008 at 12:59 pm

    where’s your VPS, noel?

  2. noel - September 9th, 2008 at 1:38 pm

    I use rapidvps.


Leave a Reply