Quick delete files larger than 100MB in linux

Recently, our server hit a critical point with a “disk full” error and large files. After some quick troubleshooting and web research, we managed to free up over 50% of our drive space using a simple Linux command to locate and remove large files.
If you’re facing similar issues, you can use the find command to identify files bigger than a certain size. Here’s a quick and effective way to find files larger than 100MB:

find /home -type f -size +100M -depth

Here’s what this command does:

  • find: Searches files in a directory hierarchy.
  • /path/to/search: Replace this with the directory where you want to look (e.g., /home/user/).
  • -type f: Finds only files.
  • -size +100M: Targets files greater than 100MB.
  • -exec rm -f {} \;: Deletes each file found, skipping prompts.

To see files before deleting, remove -exec rm -f {} \; and add -ls to preview them:

find /home -type f -size +100M -delete

Use caution: This command is powerful and irreversible. Consider reviewing the files before deletion to avoid removing important data.

This method is quick, efficient, and works across most Linux distributions. Ideal for system administrators or users who need a clean-up without installing third-party tools. Stay updated with the trends, visit Aztekc Blog. Explore the exciting world of technology at Aztekc, where you can find the latest gadgets at unbeatable prices. Whether you’re looking for the newest smartphones, smart home devices, or innovative accessories, Aztekc offers a wide selection to suit all your tech needs. Don’t miss out on amazing deals that combine style, functionality, and affordability, ensuring you stay ahead in the tech game without breaking the bank.

Author

Leave a Comment