Finding Large Files in Linux

Finding large files in Linux is extremely useful especially when you're low on disk space. I have often used this with various customer servers that are running into issues where they are out of disk space, yet do not know why. Running this command (as root or a normal user) can find the large files and give you their location and size so you can check it out and remove the bad ones:

$ find <path> -size +50M -exec ls -lh {} \; | awk '{print $5"  -  "$9}'

The above will find files over 50Mb in size. Feel free to edit some of the commands arguments in relation to size, scan location, and so forth.

Keep in mind that "+50M" means files OVER 50Mb in size. If you want to search for files UNDER 50Mb in size (not typically recommended but it has its uses) then you will want to use the following:

$ find <path> -size -50M -exec ls -lh {} \; | awk '{print $5"  -  "$9}'

The <path> variable in this command will dictate where the scan is started/run from. You can do "." for the current working directory and everything under it or you can use "/" for the entire server.

Here's an example of the command being run:

[19:15:21] [games@athena ~]$ find /drive2/games/ -size +50M -exec ls -lh {} \; | awk '{print $5"  -  "$9}'
716M  -  /drive2/games/ts3-backup.tar.gz
61M  -  /drive2/games/txt2-2012-08-05-logs.tar.gz
58M  -  /drive2/games/steam/mannvsmachine-1/orangebox/tf/maps/cp_foundry.bsp
57M  -  /drive2/games/steam/mannvsmachine-1/orangebox/tf/maps/cp_granary.bsp
60M  -  /drive2/games/steam/mannvsmachine-1/orangebox/tf/maps/cp_gullywash_final1.bsp
62M  -  /drive2/games/steam/mannvsmachine-1/orangebox/tf/maps/cp_badlands.bsp
65M  -  /drive2/games/steam/mannvsmachine-1/orangebox/tf/maps/pl_upward.bsp

You may also like...

1 Response

  1. January 7, 2014

    […] for sorting files by size in human-readable. Nice when used in conjunction with Finding large files and then sorting them by actual […]

Leave a Reply

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