Generally on the development and staging environments have disk issues where multiple application’s are running. Sometimes we also face low disk space on production systems.
Few days back my production application goes down. After searching for half an hour, I found the application was down due to disk full on my server. So I had searches all files greater than 1 GB and then all files greater than 100 MB. There was few logs files which was large in size, which caused disk full.
In this tutorial, you will learn how to search file by their size using find command.
Search Files By Size
You can define size in KB, MB and GB formats. For example, you can define size 100K, 100M, 1G or 10G formats. Use below examples, which will help you to find files by there size and extension.
- Search all files greater than or equal to 100 MB size in root file system.
find / -type f -size +100M
- Search all files greater than 1 GB size in root file system.
find / -type f -size +1G
Search Files By Size and Extension
Instead of searching all files, you can also search files of specific extension greater than 1G B size. For example search all files with extension “.log” and size is 1 GB or more.
find / -type f -name "*.log" -size +1G