> ## Content Index
> Fetch the complete content index at: https://snubmonkey.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Use `find` to Search for Large Files on Linux.
- URL: https://snubmonkey.com/linux-find-files-by-size/
- Published: 2025-06-23T09:14:41.000Z
- Updated: 2026-10-22T22:40:22.000Z
- Description: Find files larger than a chosen size on Linux with find. Learn how to limit search depth, understand MiB thresholds, and sort results by disk usage.
- Author: yannick Coffi
- Tags: how to 🪄, linux 🐧, terminal

When a disk starts running low on space, finding the largest files is a good first step. The Linux `find` command can search files by size, and `-maxdepth` lets you limit how far the search goes.

This guide shows how to find files larger than 20 MiB, restrict the search depth, and sort results by size.

## Find files larger than 20 MiB

Search the current directory and all its subdirectories for regular files larger than 20 MiB:

```bash
$ find . -type f -size +20M

```

- `.` starts the search in the current directory.
- `-type f` matches regular files.
- `-size +20M` matches files whose apparent size is greater than 20 MiB. GNU `find` uses powers of 1024 for `M`.

`find` searches recursively by default. To search the whole filesystem, use `/` as the starting point:

```bash
$ sudo find / -type f -size +20M

```

A system-wide search may print permission errors. To hide those messages, redirect standard error:

```bash
$ sudo find / -type f -size +20M 2>/dev/null

```

Use `sudo` only when you need to inspect protected directories. Hiding errors can also hide other useful warnings, so omit the redirection while troubleshooting.

## Limit the search depth

The starting directory is depth 0\. With `-maxdepth 1`, `find` checks the starting directory itself but does not descend into its subdirectories:

```bash
$ find . -maxdepth 1 -type f -size +20M

```

To include the current directory and its immediate subdirectories, use depth 2:

```bash
$ find . -maxdepth 2 -type f -size +20M

```

The hyphen is required: `-maxdepth` is the option name.

## Sort results by size

To sort matching files by estimated disk space used, largest first, use GNU `find`, `du`, and `sort`:

```bash
$ find . -type f -size +20M -print0 | du --files0-from=- -h | sort -hr

```

`-print0` safely separates file names, including names containing spaces or newlines. `du --files0-from=-` reads those names from standard input, `-h` prints human-readable sizes, and `sort -hr` sorts those sizes in descending order.

This pipeline requires GNU Findutils and GNU Coreutils. `du` reports estimated disk space used, which can differ from a file’s apparent size because of sparse files, filesystem block allocation, or hard links.

For a simpler view of apparent file sizes (the lengths reported by file metadata), use GNU `find` to print each size in bytes and sort numerically:

```bash
$ find . -type f -size +20M -printf '%s\t%p\n' | sort -nr

```

This sorts the numeric byte counts from largest to smallest. The output is less readable, but the numbers are actual bytes and are easy to compare.

##   
Understand the size threshold

In GNU `find`, `-size +20M` means larger than 20 MiB, where 1 MiB is 1,048,576 bytes. The size test rounds up to the selected unit before applying the comparison. For an exact byte-based threshold, use the `c` suffix:

```bash
$ find . -type f -size +20971520c

```

This matches files whose apparent size is greater than 20 MiB in bytes.

## 

Use `find . -type f -size +20M` to locate large files, and add `-maxdepth` when you want to limit how far the search descends. Sort the matches with `du` to see estimated disk usage or by byte count to compare apparent file sizes. The commands shown here use GNU tools commonly available on Linux.  
  
We hope this was helpful.  
**Keep learning.** Keep **exploring. Stay secure.**