Hostxpeed
Login Get Started →
Getting Started

How to Find Large Files on Server

5 min read
22 views
Jun 10, 2026

Prerequisites

Before finding large files, make sure you have:

  • SSH access to your VPS
  • Root or sudo privileges (to search all directories)

Method 1: Find Files Larger Than 100MB

Connect to your VPS:

ssh hxroot@YOUR_SERVER_IP -p 22

Find and list files >100MB:

find / -type f -size +100M -exec ls -lh {} ; 2>/dev/null

Find and sort by size (largest first):

find / -type f -size +100M -exec ls -lh {} ; 2>/dev/null | sort -k5 -hr

Method 2: Using du and sort (Fastest)

Find largest files in /home:

du -ah /home | sort -rh | head -20

Find largest files in /var:

du -ah /var | sort -rh | head -20

Search entire filesystem (slow, be patient):

du -ah / | sort -rh 2>/dev/null | head -30

Method 3: Find Top 10 Largest Files (Fastest)

find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -10

This may take a few minutes on large disks.

Method 4: Find by Size Range

Files between 50MB and 100MB:

find / -type f -size +50M -size -100M -exec ls -lh {} ; 2>/dev/null

Files larger than 1GB:

find / -type f -size +1G -exec ls -lh {} ; 2>/dev/null

Method 5: Using ncdu (Interactive)

Install ncdu:

apt install ncdu -y

Run ncdu:

ncdu /

Navigation:

  • Arrow keys to navigate
  • Enter to go into directory
  • d to delete file/directory
  • n to sort by name
  • s to sort by size
  • q to quit

Method 6: Find by File Type

Find large log files:

find /var/log -type f -size +50M -exec ls -lh {} ; 2>/dev/null

Find large backup files:

find / -type f ( -name "*.tar" -o -name "*.tar.gz" -o -name "*.zip" ) -size +100M -exec ls -lh {} ; 2>/dev/null

Find large database files:

find /var/lib/mysql -type f -size +100M -exec ls -lh {} ; 2>/dev/null

Method 7: Find Old Large Files

Files >100MB modified more than 30 days ago:

find / -type f -size +100M -mtime +30 -exec ls -lh {} ; 2>/dev/null

Method 8: Using find with -printf (Efficient)

find / -type f -size +100M -printf "%s %p
" 2>/dev/null | sort -rn | head -10

Common Directories to Check First

  • /var/log/ - Log files
  • /var/cache/apt/archives/ - Downloaded packages
  • /tmp/ - Temporary files
  • /root/ - Root home directory
  • /home/ - User home directories
  • /var/www/ - Website files
  • /var/lib/mysql/ - Database files

Clean Up Large Files

Once you identify large files, you can:

Remove file:

rm /path/to/largefile

Truncate log file (clear contents but keep file):

echo "" > /var/log/large.log

Compress old logs:

gzip /var/log/old.log

Move to backup location:

mv /path/to/largefile /backup/location/

Monitor Large File Growth

Watch a specific directory:

watch -n 5 "du -sh /var/www"

Monitor largest files over time:

#!/bin/bash
while true; do
    clear
    echo "=== Top 10 Largest Files ==="    echo "Time: $(date)"
    find / -type f -exec du -h {} + 2>/dev/null | sort -rh | head -10
    sleep 60
done

Find and Delete Old Large Logs Automatically

Find and delete logs older than 30 days:

find /var/log -type f -name "*.log" -mtime +30 -delete

Add to cron:

0 2 * * * find /var/log -type f -name "*.log" -mtime +30 -delete

✅ You can now find and manage large files consuming disk space on your Hostxpeed VPS.

Was this article helpful?