How To Find the Largest Files on Your Linux Server

The other day I was browsing around one of our Linux servers and noticed that there was a ton of storage being used.

This machine is normally used as a staging environment for various projects and client work, so it was surprising to see that almost 8 gigs had been taken up.

find largest files on your server

 

Woah nelly!

Normally most people with this issue would have to resort to poking around their filesystem or FTP to find the files or folders taking up the space.

Instead of doing that, I decided to break out some Linux wizardry and let my server do the work for me.  If you don’t have Linux experience that’s OK!  All you need to be able to do is follow some very simple directions.

Not going to waste any more time, here is how to find the biggest files on your linux server / hosting account:

1. You need ssh access.  If you don’t have ssh access ask your host.*

2. Log into your server with root level access.*

3. Once you are at a command prompt, enter this command:

du -a / | sort -n -r | head -n 10

4.  You can run the command again to search deeper within your filesystem if you want.  For instance, if you want to only search within your home directory you would replace the “/” with “/home”.  If you want to go deeper than that you can search for sub folders within a directory.

In this case we searched /home to see which domains were taking up the largest space.

You should see something along the lines of this:

find largest files on your server

After I ran this, I realized we had just uploaded 5 .MOV files to our test server for a client website.  So nothing to worry about at all.

I also found a directory that had a ton of old backups of sites we no longer manage, that totaled almost 1 GB, so it was good to get rid of those as well (of course, after backing them up first).

What just happened??

This command basically searched your filesystem for the 10 largest files and sorted them by size.  This command is actually 3 commands piped together to form one.

This command can be very useful to search /mail directories within individual directories to see which users have the largest boxes.

If you have a cloud hosting plan that is dependent on how much space you use, this method can also come in very handy.

*disclaimerbeing logged in as root on your hosting account can seriously mess things up.  Always backup your stuff!

Patrick Coombe
Patrick Coombe is the founder and CEO of Elite Strategies Llc. Patrick takes a hands on approach to managing Elite Strategies and loves to get involved with technical projects relating to clients inbound marketing needs.
Patrick Coombe
Patrick Coombe
  0 COMMENTS
Web Development

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Info

900 Linton Blvd, Suite 104
Delray Beach, FL 33444

Phone: 561-526-8457
Toll Free: 855-353-8730
E-mail: info@elite-strategies.com
Fax: 561-526-8707