Skip to content

Tutorials Servers Beginner1 min read

How to Check Disk Space and Find Large Files on Linux

Use df, du and ncdu to see how full your server's disk is, find what's using the space, and safely clean up logs, caches and old packages.

By ZSOLNET Editorial Team Updated

Key takeaways

  • df shows how full each disk is; du shows what's using the space.
  • Logs, old backups and package caches are the usual space hogs.
  • A full disk can break databases and stop websites loading.

How full is the disk?

df -h

Look at the Use% column for /. Over 90% needs attention.

What’s using the space?

sudo du -h --max-depth=1 / 2>/dev/null | sort -h
sudo du -h --max-depth=1 /var | sort -h

For an interactive view, install ncdu:

sudo apt install ncdu
sudo ncdu /

Find large files

sudo find / -xdev -type f -size +200M -exec ls -lh {} \; 2>/dev/null

Safe clean-ups

sudo apt autoremove --purge     # unused packages
sudo apt clean                  # package cache
sudo journalctl --vacuum-size=200M
docker system prune             # if you use Docker (review what it removes)

Move old backups off the server to separate storage rather than keeping them on the same disk.

Frequently asked questions

The disk is full but du doesn't add up. Why?

A deleted file can still be held open by a running process. Find it with sudo lsof +L1 and restart that service.

Is it safe to delete files in /var/log?

Delete rotated, compressed logs (.gz, .1) freely. For active logs, truncate them or vacuum the journal rather than deleting the file.

Share X LinkedIn Facebook

Log in to your account

Manage your domains, hosting and invoices in one place.

Secure connection straight to the ZSOLNET client area.

No account yet?