How to Find Large Files in Linux

Unlike Windows, which provides visual pie charts and third-party disk analyzer software to help you understand where your storage space is going, a headless Linux server requires you to hunt for massive files using the command line. If your web server suddenly crashes because the hard drive is at 100% capacity, you must quickly identify the largest, most bloated files (which are usually out-of-control system logs or abandoned database backups) so you can delete them and restore functionality.

You cannot simply type ls to find large files, because the standard listing command does not sort by physical file size, nor does it calculate the cumulative size of entire directories. You must chain together several powerful terminal commands.

Method 1: The “du” Command (Disk Usage)

The du command is the absolute standard tool for diagnosing storage bloat. However, running it by itself will spit out a terrifying, unreadable list of thousands of files in bytes.

You must use specific flags to make the output human-readable, and you must “pipe” (|) that output into the sort command to organize it from largest to smallest.

  1. Open your terminal or SSH into your server.
  2. To scan the entire server and list the absolute largest files and directories, type this exact command:
sudo du -ah / | sort -rh | head -n 20

Let’s break down exactly what this command is doing so you understand the logic:

  • sudo: You must run this as an administrator, otherwise Linux will deny you permission to scan system-level folders.
  • du: Execute the disk usage tool.
  • -ah: The a flag tells it to scan all files and folders. The h flag tells it to print the sizes in “human-readable” format (Megabytes and Gigabytes, instead of raw bytes).
  • /: This tells the tool to start scanning at the absolute root of the hard drive.
  • | sort -rh: This pipes the massive data output into the sorting engine. The r means reverse (largest at the top), and the h means understand human-readable numbers (so it knows 2G is larger than 900M).
  • | head -n 20: This tells the terminal to only print the top 20 worst offenders on the screen, rather than flooding your terminal with 10,000 lines of text.

The output will instantly show you exactly which folder (or specific file) is eating the majority of your hard drive.

Method 2: The “find” Command (Targeting Specific Sizes)

If you don’t want a massive list of folders, and you just want the terminal to hunt down and expose specific, gigantic files (for example, any single file larger than 1 Gigabyte), you should use the find command instead.

  1. Open your terminal.
  2. Type this command:
sudo find / -type f -size +1G
  • /: Start searching at the root directory.
  • -type f: Only look for actual files, ignore directories.
  • -size +1G: Only return files that are larger (+) than 1 Gigabyte. (You can change this to +500M for 500 Megabytes).

The terminal will print a clean, simple list of the file paths for every massive file on the server. For example, it might reveal /var/log/syslog.1, immediately showing you that an old system log is the culprit.

How to Safely Delete the Bloat

Once you have identified a massive 5GB file using the commands above, you can delete it using the standard rm (remove) command.

sudo rm /var/log/massive_broken_log_file.txt

Massive Warning: Do not delete files if you do not know exactly what they are. Deleting a 5GB .img or .vmdk file might instantly destroy a virtual machine running on your server. Only delete user-created backups, temp files, or rotated logs (files that end in .log.1 or .gz).

Get the best tech tips delivered straight to your inbox.

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