The best way to find large files on your Linux system is to use the command line. This how-to will suggest a few methods for listing such files in specific directories or complete file systems.
This is a basic method for listing files of a certain size. Here we're searching the home directory of the user you're currently logged in as for files greater than 20MB.find ~ -size +20M
For more detailed output, we can use find to search directories for files greater than 20MB, display the path and file size. In this example we're searching the entire file system, but you may choose to use a specific path.find / -type f -size +20M -exec ls -lh {} \; | awk '{ print $NF ": " $5 }'
Find reports errors when it searches directories for which it has no permissions. This is attributed to not having administrative privileges, so you may want to su to root, otherwise, discard these errors by redirecting to /dev/null.
find / -type f -size +20M -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }'
Additionally, you may find it beneficial to sort (numerically) based on the size (second column).
find / -type f -size +20M -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nk 2,2
Or reverse the sort order (larger files listed first) by using this.
find / -type f -size +20000k -exec ls -lh {} \; 2> /dev/null | awk '{ print $NF ": " $5 }' | sort -nrk 2,2
Article Number: 426
Posted: Mon, Oct 29, 2018 10:48 PM
Last Updated: Mon, Oct 29, 2018 10:48 PM
Online URL: http://kb.ictbanking.net/article.php?id=426