How to find large files in Unix and Linux

ls_example

When a Linux or Unix server runs out of disk space, the fastest way to recover control is to identify the largest files and directories first. This guide collects practical commands for finding what is consuming storage without installing extra tools.

List large files in the current directory

To sort files by size in the current directory, use:

ls -alSh

The -S option sorts by size and -h prints human-readable values.

Find files larger than 100 MB

To scan the whole filesystem and hide permission errors:

find / 2>/dev/null -type f -size +100M

Adjust +100M to match the threshold you need.

Show the top space consumers

This command displays the ten largest paths in megabytes:

sudo du -aBm / 2>/dev/null | sort -nr | head -n 10

Safe cleanup checklist

Before deleting anything, confirm whether the file belongs to logs, backups, cache, uploads or application data. For logs, prefer rotation or truncation instead of removing active files. For backups, verify there is a recent copy outside the server.

Disk cleanup is safer when you understand the owner and purpose of each file.

Leave a Reply