Advertisement
linuxserver A full disk on a Linux server can cause crashes, slow performance, and application errors. The first step to fixing it is identifying which files or directories are taking up the most space. In this tutorial, you’ll learn step-by-step, beginner-friendly methods to locate large files, understand what’s filling your disk, and clean up safely

Disk Is Full? How to Find Large Files on Linux (Beginner Friendly Guide)

5 Min Read Verified Content

# Step 1 — Check Disk Usage Overview


Start by checking which partition is full:

df -h

Example output:

Filesystem Size Used Avail Use% Mounted on /dev/sda1 20G 19G 1G 95% /
  • Use% = 95% → This partition is almost full

  • Focus cleanup here




## Step 2 — Identify Which Directories Use the Most Space


Use du (disk usage) command:

sudo du -h --max-depth=1 / | sort -hr

Explanation:

  • du -h → human-readable sizes

  • --max-depth=1 → show top-level folders only

  • sort -hr → sort from largest to smallest

Example output:

8.5G /var 5.2G /home 3.0G /usr
  • /var is the biggest folder → check inside




## Step 3 — Drill Down into Large Directories


Go into the largest folder, e.g., /var:

cd /var sudo du -h --max-depth=1 | sort -hr

Common culprits:

  • /var/log → large log files

  • /var/cache → package caches

  • /var/lib/mysql → databases

  • /var/tmp → temporary files



## Step 4 — Find Individual Large Files


To locate files bigger than, for example, 500MB:

sudo find / -type f -size +500M -exec ls -lh {} \; | awk '{ print $NF ": " $5 }'

Explanation:

  • -type f → only files

  • -size +500M → bigger than 500MB

  • ls -lh → human-readable size

  • awk → print file path and size

This gives a clear list of huge files to review.




## Step 5 — Use ncdu for Easier Navigation


ncdu is an interactive tool to explore disk usage.

Install:

sudo apt install ncdu -y # Debian/Ubuntu sudo yum install ncdu -y # CentOS/RHEL

Run:

sudo ncdu /
  • Navigate with arrow keys

  • Identify large directories and files easily

  • Delete safely from within ncdu using d key




## Step 6 — Check Log Files


Logs can grow very fast. Check /var/log:

sudo du -sh /var/log/*

Common large log files:

  • syslog

  • auth.log

  • mysql/error.log

  • apache2/access.log

Clean logs safely:

sudo truncate -s 0 /var/log/syslog sudo truncate -s 0 /var/log/mysql/error.log


## Step 7 — Clean Package Cache


Package managers often store old packages in cache:

Debian/Ubuntu

sudo apt clean

CentOS/RHEL

sudo yum clean all

Fedora

sudo dnf clean all


## Step 8 — Remove Old Kernels (Debian/Ubuntu)


Old Linux kernels can take GBs of space:

dpkg --list 'linux-image*' | grep ^ii sudo apt autoremove --purge


## Step 9 — Check User Home Directories


Sometimes users store huge files in /home:

sudo du -sh /home/*

Delete or move unnecessary large files to external storage or cloud.




## Step 10 — Set Up Disk Monitoring


To prevent future disk-full situations:

  • Install monitoring tools: Netdata, Glances, or Grafana + Prometheus

  • Schedule automated cleanup: cron jobs for /tmp or /var/cache

  • Alert when disk usage > 80%

Example cron job to clean temp files:

sudo crontab -e # add: 0 3 * * * /usr/bin/find /tmp -type f -atime +7 -delete

Deletes files older than 7 days daily at 3AM.




## Beginner-Friendly Checklist


IssueDiagnosisFix
Partition almost fulldf -hFocus cleanup on this partition
Largest directoriesdu -h --max-depth=1 /Drill down and identify culprit
Large individual filesfind / -type f -size +500MDelete or move
Log files/var/logTruncate or rotate
Package cacheapt/yum cleanFree space safely
Old kernelsdpkg --list + apt autoremoveRemove old kernels
User files/homeMove or delete unnecessary files


## Conclusion


A full Linux disk doesn’t have to be scary. By systematically checking:

  • Disk usage by partition

  • Largest directories

  • Individual large files

  • Logs, caches, old kernels, and user files

You can reclaim gigabytes of space safely. Use ncdu for interactive cleaning, set up monitoring, and schedule regular maintenance to prevent the disk from filling up again.

Advertisement
Back to Linuxserver