How to Find large files on Linux Server

Hard Disk Drive

One of the biggest problems with servers is administrators not keeping track of the disk space been used, usually this is only realised when it gets too late. Running out of disk space can be very serious and most of the time can actually stop a server from running or even booting. I will be doing a howto on installing ‘munin’ soon, I highly suggesting doing this as you can get some great disk usage graphs from this script, and even alerts before it’s too late.

If your getting low on disk space or just want to keep and eye on things you should probably have a look around for the big files on your storage media, the following command will make a list of all the files over 20MB from the ‘/’ root of your system:

find / -type f -size +20000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

This isn’t really anything fancy and will work on almost any linux system out there, keep an eye out for large log files as these are generally the biggest culprit and can most of the time just be removed. If you do find large log files locate the script creating them and work out why these are created, and try to stop it or setup some kind of automated purge.

Having a look at the last few lines is always a good idea:

tail -n 100 [file path here]

Deleting the files is fairly easy just copy the path into the following command, be sure you don’t need the file though!!!

rm -f [file path here]

You might need to prepend the ‘sudo’ command if your not logged in as ‘root’

Technology enthusiastic with many ongoing online projects one of which is this personal blog PingBin. While also working full time within a data center designing and maintaining the network infrastructure.

Leave a reply:

Your email address will not be published.

Site Footer