🧹 How to Find Large Files on Ubuntu 18.04 (and Clean Up Disk Space)
If you’ve ever run into the dreaded “No space left on device” error on your Linux system, you’re not alone. Over time, log files, package caches, and forgotten downloads can fill up your disk. In this guide, we’ll walk through several ways to identify large files and directories on your Ubuntu 18.04 system — using both command-line tools and interactive utilities.
📁 Why You Might Need This
- Your system is running low on disk space.
- You’re managing a server and want to optimize storage.
- You want to clean up unused data before creating a backup.
- You’re just curious what’s eating up all your GBs.
🔍 Method 1: Find Large Files Using
find
Let’s say you want to find files larger than 100 MB:
sudo find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null | sort -k 5 -hr | head -n 20
What this does:
-
find /
— search the whole system
-
-type f
— look for files only
-
-size +100M
— files larger than 100 megabytes
-
ls -lh
— show file size in human-readable format
-
sort -k 5 -hr
— sort files by size, descending
-
head -n 20
— show only the top 20 results
🔐 Note: You may need
sudoto access some directories.
📦 Method 2: Show Largest Directories with
du
To find out which folders are taking up the most space, use:
du -h --max-depth=1 | sort -hr
This lists the size of each subdirectory in the current folder. Example output from
/var
:
3.4G ./log 1.2G ./cache 5.0G .
You can also search the whole system:
sudo du -ah / | sort -rh | head -n 30
This command lists the 30 biggest files and folders system-wide.
🖥️ Method 3: Use
ncdu
– The Friendly Disk Usage Viewer
Prefer something more visual and interactive? Try
ncdu
:
Install it:
sudo apt update sudo apt install ncdu
Run it:
sudo ncdu /
Navigate the disk usage tree using arrow keys. Press
d
to delete files directly from within the tool (be careful!).
🧼 Bonus Tips: Clean Up with Built-in Tools
Clear APT cache:
sudo apt clean
Remove old kernels (Ubuntu auto handles this, but still):
sudo apt autoremove --purge
Check disk space usage at a glance:
df -h
🔚 Wrapping Up
Identifying and removing large files can dramatically improve system performance and free up valuable space. Whether you’re a sysadmin managing a fleet of servers or just cleaning up your dev laptop, these tools will help you stay in control.
💬 What’s your favorite way to clean up disk space on Linux?
Feel free to share your tips in the comments box below this blog post or contribute to the conversation on Reddit, X (Twitter), or your favorite dev community.