HowTo: Find Large Files in Linux

Finding the largest files is extremely useful especially when you you’re low on disk space and want to free it up.

The best way to find the largest files on your Linux system is to use the command line.

Actually there is no simple command to list the largest files in Linux.

However, you can easily find the largest files, using a combination of the several simple commands.

Find The Largest Files in Linux

Run the combination of the following commands to find the largest files on your Linux system, beginning from the <DIR> directory (change <DIR> to whatever directory you need), and list top 10 of them.

$ find <DIR> -mount -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'

Find 10 largest files, starting from ‘/’ (root)

$ find / -mount -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'

       106 MB	/var/lib/mysql/ibdata1
        94 MB	/usr/lib/locale/locale-archive
        41 MB	/scripts/20130206-015833.tar.gz
        41 MB	/scripts/20130206-004839.tar.gz
        41 MB	/scripts/20130206-130400.tar.gz
        41 MB	/scripts/20130206-000442.tar.gz
        41 MB	/scripts/20130206-132019.tar.gz
        41 MB	/root/20130208-133954.tar.gz
        33 MB	/var/log/messages-20130303
        32 MB	/var/lib/rpm/Packages

Find 10 largest files, starting from ‘/home’

$ find /home -mount -type f -ls 2> /dev/null | sort -rnk7 | head -10 | awk '{printf "%10d MB\t%s\n",($7/1024)/1024,$NF}'

      3007 MB	/home/user/Desktop/share/linux-65835.iso
       448 MB	/home/user/Pictures/Turkey/SAM_4590.AVI
       266 MB	/home/user/Pictures/Turkey/SAM_4588.AVI
       173 MB	/home/user/Camera/VID_20130909_120713.mp4
       152 MB	/home/user/Camera/VID_20130909_115427.mp4
       133 MB	/home/user/Camera/VID_20130909_210904.mp4
       133 MB	/home/user/Pictures/Paris/VID_20130928_182431.mp4
       131 MB	/home/user/Pictures/Turkey/SAM_4597.AVI
       129 MB	/home/user/Pictures/Turkey/SAM_4641.AVI
       127 MB	/home/user/Desktop/tmp/Camera/VID_20130911_164440.mp4
Was it useful? Share this post with the world!

Leave a Reply