How to Find Files by Specific Size in Ubuntu Linux

The Storage Hunt

When an Ubuntu Linux server runs out of hard drive space, the entire operating system can crash. Often, the culprit is not a million tiny files, but a single, massive file—such as a runaway error log or an abandoned database backup that has swollen to 50 Gigabytes. Manually clicking through directories with the ls command to find these massive files is impossible. You must instruct the Linux search engine to filter the entire filesystem strictly by the byte size of the documents.

Using the find Command with -size

The Linux find command utilizes the -size flag to search for files based on exact, greater-than, or less-than mathematical parameters.

  1. Open your Terminal application (Ctrl + Alt + T) or log into your server via SSH.
  2. To search the entire /var/log/ directory for any files that are larger than 1 Gigabyte, type the following command exactly:
  3. sudo find /var/log/ -type f -size +1G
  4. Press Enter and provide your administrator password.

Understanding the Syntax

The syntax of the -size flag is very strict. The plus sign (+) means “greater than.” If you used a minus sign (-1G), it would find files smaller than 1 Gigabyte. The capital G stands for Gigabytes. You can also use M for Megabytes (e.g., -size +500M to find files larger than 500 MB) or k for kilobytes (must be lowercase). This command will instantly print a list of the largest files on your server, allowing you to quickly delete them and restore your server’s stability.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.