# How do I find the largest files on a Linux server?

Find the largest files on a Linux server with find -size and du, stay on one disk with -xdev, and trace deleted files that a program still holds open.

Source: https://valakes.com/learn/find-large-files/

Last updated: 2026-11-27

Run find /path -type f -size +100M to list the files above 100 MiB, or du -ah /path | sort -h | tail to see the biggest files and folders together. Add -xdev so find stays on one disk. If df says the disk is full and du cannot find the space, look for deleted files that a program still holds open with lsof +L1.

Commands checked on Ubuntu 24.04.5 LTS (the ubuntu:24.04@sha256:562111b88caa79c71391c0c4d3c2114a7d5c35915c20561fd893cb1e07929e6b container image), 25 November 2026.

Use `find /path -type f -size +100M` to list the files above 100 MiB, or `du -ah /path | sort -h | tail` to see the biggest files and folders in one list. Both take seconds on a small tree and minutes on a whole server, so start in the folder that [the disk space article](https://valakes.com/learn/check-disk-space/) points at.

## List the files above a size

The server has a data folder with a few big files. This command prints the ones above 10 MB with `ls`:

```console
$ find /srv/data -type f -size +10M -exec ls -lh --time-style=long-iso {} +
-rw-r--r-- 1 dev dev 30M 2026-11-20 08:00 /srv/data/backups/db-nightly.sql.gz
-rw-r--r-- 1 dev dev 20M 2026-11-20 08:00 /srv/data/logs/app.log
-rw-r--r-- 1 dev dev 11M 2026-11-20 08:00 /srv/data/tmp/just-over.bin
-rw-r--r-- 1 dev dev 11M 2026-11-20 08:00 /srv/data/uploads/video.mp4
```

`-type f` limits the search to files. `-size +10M` means larger than 10 MiB. The units are `c` for bytes, `k` for KiB, `M` for MiB and `G` for GiB. Without a unit the number counts blocks of 512 bytes. The `+` at the end of `-exec` hands many files to one `ls`, which then sorts them by name, not by size.

To sort by size, print the size in bytes and let `sort` do it:

```console
$ find /srv/data -type f -printf '%s %p\n' | sort -n | tail -3
11534336 /srv/data/uploads/video.mp4
20971520 /srv/data/logs/app.log
31457280 /srv/data/backups/db-nightly.sql.gz
```

### Sizes are rounded up

`find` rounds a file's size up to a whole unit before it compares. The folder `/srv/data/tmp` has one file of exactly 10 MiB and one of 10 MiB plus one byte:

```console
$ find /srv/data/tmp -type f -size +10M
/srv/data/tmp/just-over.bin
$ find /srv/data/tmp -type f -size 10M
/srv/data/tmp/exact10.bin
$ find /srv/data/tmp -type f -size +10485760c
/srv/data/tmp/just-over.bin
```

The file with one extra byte counts as 11 MiB, so `+10M` matches it and plain `10M` does not. The exact file counts as 10 and matches `10M`. When the border matters, count in bytes with `c`, as in the last command.

## See folders and files in one list

`du -a` prints every file as well as every folder, and `sort -h` puts the biggest at the end:

```console
$ du -ah /srv/data | sort -h | tail -6
20M	/srv/data/logs/app.log
21M	/srv/data/logs
21M	/srv/data/tmp
30M	/srv/data/backups/db-nightly.sql.gz
31M	/srv/data/backups
85M	/srv/data
```

A folder appears with the sum of what is inside. The last line is the whole tree, and the line above it is the biggest folder in it. Read upward to find the file that makes the folder big.

## Stay on one file system

A server has several file systems under one tree. `find /` also walks into `/proc` and `/sys`, into other disks and into network mounts. The option `-xdev` keeps `find` on the file system where each start point lives. `/dev` is a file system of its own, and `/dev/shm` is another one inside it:

```console
$ find /srv /dev -type f -size +25M | sort
/dev/shm/dump.bin
/srv/data/backups/db-nightly.sql.gz
$ find /srv /dev -xdev -type f -size +25M | sort
/srv/data/backups/db-nightly.sql.gz
```

Use `-xdev` when one disk is full. Files on the other disks cannot be the reason, and the search gets much shorter. `du` has the same option, `-x`.

## The disk is full, but no file is big

Sometimes `df` says the disk is almost full and `du` finds much less. A program may keep a file open after someone deleted it. The name is gone, so `find` and `du` cannot see it, but the space stays in use until the program closes the file. Here a program holds a 20 MB debug log on the small file system. First the numbers, then the delete:

```console
$ df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
shm              64M   55M  9.0M  86% /dev/shm
$ du -sh /dev/shm
55M	/dev/shm
$ rm /dev/shm/app-debug.log
$ df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
shm              64M   55M  9.0M  86% /dev/shm
```

The file is gone and the disk is as full as before. `lsof +L1` lists the open files that have no name left, because their link count is below 1. The awk part leaves out the PID, the device number and the inode, which differ from run to run. You need the PID in a moment, so the next command asks for it with `-t`:

```console
$ lsof +L1 | awk '{print $1, $3, $4, $5, $7, $8, $10, $11}'
COMMAND USER FD TYPE SIZE/OFF NLINK NAME
app-worke dev 0r REG 20971520 0 /dev/shm/app-debug.log (deleted)
```

The program `app-worker` holds the file on descriptor 0 (the `0r` in the FD column), and the name carries the word `(deleted)`. A program that writes a log shows `w` or `u` after the number. You can end this in two ways. Restart the program, and the kernel frees the blocks when it closes the file. Or empty the file through `/proc`, while the program runs:

```console
$ pid=$(lsof -t +L1); readlink /proc/$pid/fd/0
/dev/shm/app-debug.log (deleted)
$ : > /proc/$pid/fd/0
$ df -h /dev/shm
Filesystem      Size  Used Avail Use% Mounted on
shm              64M   35M   29M  55% /dev/shm
```

`: > file` writes nothing and cuts the file to zero bytes. The 20 MB came back. `lsof` as a normal user sees only your own processes. For the whole machine run it with `sudo`, and read [which process uses a port](https://valakes.com/learn/process-on-port/) for why.

## Mistakes people make

You leave out the unit. `-size +100` means 100 blocks of 512 bytes.

You run `find /` without `-xdev` and wait while it reads `/proc`.

You delete the big file and the disk stays full. Check for open deleted files before you look for more to remove.

You delete first. Print the list, read it, and only then add `-delete` or write the `rm`. [Safe rm on servers](https://valakes.com/learn/safe-rm-on-servers/) has the habits that keep a wrong path from costing you a server.

You forget that logs can be big on purpose. Before you cut a log, read the end of it, as in [the logs article](https://valakes.com/learn/read-server-logs/).

## In Valakes

The Files panel in Valakes lists a server folder and sorts it by size, and a delete there always asks first. It has no sudo, so it shows only what your login can read, and it does not replace du for a whole disk. [Feature: Files](https://valakes.com/features/files/)

[Read the docs: Files](https://docs.valakes.com/files/)

## Questions

### Why does find -size +100 list files of a few kilobytes?

A number without a unit counts blocks of 512 bytes, so +100 means more than 51,200 bytes. Always write the unit, for example +100M.

### How do I find the biggest folders instead of files?

Run du -h --max-depth=1 on the path and sort the lines with sort -h. Repeat inside the biggest folder. The disk space article shows it step by step.

### Can I free the space of a deleted file without restarting the program?

Often yes. Find the process and the file descriptor with lsof +L1, then empty the file through /proc, as in the last step of the article. The blocks come back and the program keeps running with an empty file.

## References

- [find(1) on Ubuntu 24.04, the tests -size and -type and the option -xdev](https://manpages.ubuntu.com/manpages/noble/man1/find.1.html)
- [du(1) on Ubuntu 24.04, the options -a, -h and -x](https://manpages.ubuntu.com/manpages/noble/man1/du.1.html)
- [du(1) at man7.org, the options -a, -h and -x](https://man7.org/linux/man-pages/man1/du.1.html)
- [lsof(8) on Ubuntu 24.04, the +L option](https://manpages.ubuntu.com/manpages/noble/man8/lsof.8.html)

## Related articles

- [How do I check disk space on a Linux server?](https://valakes.com/learn/check-disk-space/): Run df -h to see how full each file system is, then run du -h --max-depth=1 on the full one to find the folder that uses the space. df reads the file system itself and du adds up the files it can reach, so the two can disagree.
- [How do I read logs on a Linux server?](https://valakes.com/learn/read-server-logs/): Use tail -f to watch a log file live, grep -C 3 to see a match with the lines around it, and zgrep for the rotated copies that are compressed. For a service that logs to systemd, run journalctl -u name --since "1 hour ago". You need sudo or the right group for the journal.
- [How do I find which process is using a port on Linux?](https://valakes.com/learn/process-on-port/): Run sudo ss -tulpn and look for the port in the Local Address column. The last column names the program and its PID. lsof -i :PORT answers the same question for one port. Without sudo `ss` still lists every listener but names only your own processes.
- [How do I use rm safely on a server?](https://valakes.com/learn/safe-rm-on-servers/): List what a command will remove before you run it, with ls, find or echo. Use rm -I so that rm asks once before a recursive delete, and write variables as "${dir:?}" so that an empty one stops the command. The built-in --preserve-root protects only the path /.
