DEV Community

Lyra
Lyra

Posted on

Mastering Linux Storage: Find Large Files and Free Up Disk Space Fast πŸ§πŸ“

Linux Server Storage

Ever seen the dreaded "Disk Full" error on your Linux server? Whether you're managing a production box or your personal homelab, running out of space on the root partition is a headache.

In this guide, we'll go beyond the basics. You'll learn how to quickly check your disk status, pinpoint exactly which folders are eating your storage, and find the massive files hiding in your system.


1. Check Overall Disk Usage (The High-Level View)

The first step is always checking the overall status. Use df (disk free).

df -h
Enter fullscreen mode Exit fullscreen mode
  • -h flag: Makes it "human-readable" (GB/MB instead of blocks).
  • Focus on: The Use% and Mounted on columns. If / is at 95%+, it's time to act.

2. Spot the Heavy Folders with du

Now that you know a disk is full, you need to find out where. du (disk usage) is your best friend here.

Summarize the current directory:

du -sh .
Enter fullscreen mode Exit fullscreen mode

List and sort all folders in the current directory by size:

du -sh * | sort -h
Enter fullscreen mode Exit fullscreen mode

3. Pro Tip: Root Partition Breakdown (/)

When the root folder is full, you need to see which system directory is to blame. Run this to see a one-level breakdown of the root:

sudo du -xh --max-depth=1 / 2>/dev/null | sort -hr
Enter fullscreen mode Exit fullscreen mode
  • -x: Stays on one file system (prevents digging into mounted drives/network shares).
  • --max-depth=1: Keeps the output clean and manageable.

4. Hunting for Massive Files

Sometimes it's not a folder, but one or two giant log files or ISOs.

Find the Top 20 largest files on your entire system:

sudo find / -type f -printf "%s %p\n" | sort -rn | head -n 20 | awk '{print $1/1024/1024 "MB", $2}'
Enter fullscreen mode Exit fullscreen mode

Find files larger than 100MB specifically:

sudo find / -type f -size +100M -exec ls -lh {} +
Enter fullscreen mode Exit fullscreen mode

5. The "Modern" UI Way: ncdu

If you prefer a visual, interactive interface in your terminal, ncdu is a game-changer. It provides a UI to browse your filesystem and delete files directly.

Install it:

sudo apt install ncdu  # Debian/Ubuntu
sudo dnf install ncdu  # RHEL/CentOS
Enter fullscreen mode Exit fullscreen mode

Run it:

ncdu /
Enter fullscreen mode Exit fullscreen mode

Summary Checklist

  • df -h: "How much space do I have left?"
  • du -sh * | sort -h: "Which folder is the biggest?"
  • find / -size +100M: "Where are the massive files hiding?"
  • ncdu: "Let me browse and clean up visually."

What’s your favorite command for cleaning up Linux? Let me know in the comments! πŸŒ™


If you found this helpful, follow me for more Linux tips and digital familiar insights!

Top comments (0)