ThisCalculator

Everyday

Search Files by Size in Linux: Easy Methods

Updated · Standard formula, shown below

Search Files by Size in Linux: Easy Methods

To search for files by size in Linux, use the find command with the -size option, for example find /home -type f -size +100M finds all files larger than 100 MB in /home. You can also use ls, du, and graphical file managers for similar results, each with different strengths for speed, detail, and ease of use.

Why Search by File Size?

Finding files by size is a common administrative task. You might be running out of disk space and need to locate large files to delete or archive. You might be cleaning up a home directory, auditing a server, or checking for unexpectedly large log files or database dumps. Searching by size lets you quickly identify the biggest consumers of storage, which is often the first step in freeing up space or enforcing storage policies.

The find Command: The Standard Tool

The find command is the most powerful and flexible way to search for files by size. It recursively scans directories and applies tests you specify. The basic syntax is:

find [path] [options] -size [size]

The -size test accepts a number followed by a unit suffix. Common suffixes are:

  • c – bytes
  • k – kibibytes (1024 bytes)
  • M – mebibytes (1024 * 1024 bytes)
  • G – gibibytes (1024 * 1024 * 1024 bytes)

You can also use a plus sign (+) for “greater than�, minus (-) for “less than�, or no sign for “exactly�. For example:

  • find . -type f -size +1G – files larger than 1 GiB
  • find . -type f -size -10k – files smaller than 10 KiB
  • find . -type f -size 100c – files exactly 100 bytes

To make the output more readable, you can combine find with ls or du, or use -exec to run a command on each found file. For example, to list large files with human-readable sizes:

find /var -type f -size +100M -exec ls -lh {} \;

Using du to Find Large Directories and Files

While find searches by the file’s size attribute, du (disk usage) measures the actual disk space used, including block overhead. This is useful when you want to see which directories are consuming the most space, and then drill down to specific files. A common pattern is:

du -ah /home | sort -rh | head -20

This lists all files and directories in /home with their sizes, sorts them in reverse human-readable order, and shows the top 20. You can also use du -h --max-depth=1 to see just the top-level subdirectories, which helps you locate the biggest container before diving deeper.

Graphical Alternatives: File Managers and Disk Usage Analyzers

If you prefer a graphical interface, most Linux file managers (like GNOME Files, Dolphin, or Thunar) have a search feature that allows filtering by size. Typically, you open the search bar, type a name pattern or leave it empty, and then add a “Size� condition (e.g., “is greater than 100 MB�). This is the easiest method for casual users who are not comfortable with the command line.

For a more visual overview of disk usage, tools like baobab (Disk Usage Analyzer) or ncdu (a terminal-based tool) show a graphical or interactive map of where space is used. They are not strictly “search� tools, but they help you spot large files and directories quickly.

Common Pitfalls and How to Avoid Them

One common mistake is forgetting the -type f option, which causes find to also list directories that match the size criteria. Directories have a size too, but it is usually small and not what you want. Always include -type f unless you specifically want directories.

Another issue is the difference between decimal and binary units. The find command uses binary units (1M = 1,048,576 bytes), while some other tools (like ls with --block-size=MB) may use decimal units (1 MB = 1,000,000 bytes). This can lead to confusion when you think you are searching for “100 MB� but the command looks for 100 MiB. Always check the man page or documentation for the unit convention.

Also, be careful with permissions. find may return “Permission denied� errors for directories you cannot read. You can suppress these errors by redirecting stderr: find / -type f -size +1G 2>/dev/null.

Performance and Large Directories

Searching an entire filesystem can be slow, especially on mechanical hard drives. To speed things up, narrow the search path to the most likely location (e.g., /home instead of /). You can also use the -xdev option to prevent find from crossing into other mounted filesystems, which is useful if you have network mounts or separate partitions.

For very large filesystems, consider using a database-backed search tool like locate (updatedb) but note that it does not index file sizes by default. Some systems allow you to configure updatedb to store size information, but this is not standard. In practice, find is usually fast enough for most tasks.

Frequently Asked Questions

How do I find files larger than 1GB in Linux?

Use find / -type f -size +1G (replace / with the directory you want to search). Add 2>/dev/null to hide permission errors. To see the file sizes, pipe to ls -lh or use -exec ls -lh {} \;.

Can I search for files smaller than a certain size?

Yes, use the minus sign: find . -type f -size -10k finds files smaller than 10 KiB. You can also combine conditions with -a (and) or -o (or), e.g., find . -type f -size +1M -a -size -10M finds files between 1 MiB and 10 MiB.

Why does find return “Permission denied� errors?

You do not have read permission for some directories. Run the command with sudo to search as root, or redirect errors to /dev/null to ignore them. Be careful with sudo – it may take longer and expose files you normally cannot see.

What is the difference between find -size and du?

find -size checks the file’s logical size (the number of bytes in the file as reported by the filesystem). du reports the actual disk usage, which may be larger due to filesystem block allocation, or smaller for sparse files. For most purposes, the logical size is what you want when searching.

How do I find the largest files in a directory?

Use ls -lS to list files sorted by size, or use find . -type f -printf '%s %p\n' | sort -rn | head to get the top 10 largest files. The du approach with sort -rh also works.

Is there a way to search by size in GNOME Files (Nautilus)?

Yes, open the search bar (Ctrl+F), type a name or leave it blank, then click the magnifying glass icon to add a search condition. Choose “Size� and set the comparison (e.g., “is greater than�) and the value. This works in most current versions of GNOME Files.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.