Overview
Disk usage problems are one of the most common support tickets we see on shared hosting, VPS, and dedicated servers alike. A full disk doesn’t just mean you can’t upload files — it can crash running services, corrupt databases, and make your server completely unresponsive. Knowing how to check disk usage on Linux quickly and accurately is a core skill for anyone managing a server.
Linux gives you two primary tools for this: df, which shows you how full your mounted filesystems are, and du, which drills into directories to find out exactly what’s taking up space. They’re complementary — df tells you that you have a problem, du tells you where it is.
This article covers both commands with real hosting examples — including the non-obvious stuff that trips people up, like deleted files that still hold disk space, and why df and du sometimes report different numbers.
Prerequisites
- SSH access to your Linux server (root or sudo user)
- A terminal client — PuTTY on Windows, Terminal on macOS/Linux
- Basic comfort with the command line (you don’t need to be an expert)
- These commands work on any modern Linux distribution: Ubuntu 20.04+, Debian 11+, CentOS 7+, AlmaLinux 8/9, Rocky Linux 8/9
Step 1: Check Overall Filesystem Disk Usage with df
Start here. Before hunting through directories, get a high-level view of all your mounted filesystems.
df -h
The -h flag means human-readable — it shows sizes in GB and MB instead of raw kilobyte blocks. Your output will look something like this:
Filesystem Size Used Avail Use% Mounted on
/dev/vda1 50G 43G 7.0G 87% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/vda2 100G 12G 88G 12% /home
Focus on the Use% column and the Mounted on column. If your root filesystem (/) is at 90% or above, you’re in the danger zone. At 100%, your server will start failing in unpredictable ways.
📝 Note: On cPanel servers, /home is usually a separate partition where all user accounts and website files live. Check both / and /home independently.
If you want to check a specific filesystem or directory’s total allocation:
df -h /home
Step 2: Check Inode Usage
Here’s something that catches a lot of people off guard. Your disk can show free space but your server still refuses to create new files. The culprit is usually inodes.
Every file and directory on a Linux filesystem uses one inode — a metadata slot. Some partitions run out of inodes long before they run out of raw storage, especially on servers hosting lots of small files (email servers and WordPress sites with thousands of cache fragments are classic offenders).
df -i
Output looks like this:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/vda1 3276800 3276799 1 100% /
/dev/vda2 6553600 280000 6273600 4% /home
⚠ Warning: If IUse% is at 100% on any partition, file creation will fail completely on that partition — even if df -h shows plenty of free space. This is one of the most confusing situations on a Linux server because the error messages don’t always make the inode issue obvious.
I’d recommend running df -ih (combines inode and human-readable output) as part of any routine disk health check.
Step 3: Find What’s Using Space with du
Once you know a filesystem is filling up, use du to find out what’s actually in there. Running du on / without arguments will produce thousands of lines and take a while — use these targeted approaches instead.
Find the top space consumers in the current directory:
du -sh * | sort -rh | head -20
Breaking that down: -s gives a summary per item instead of recursing into every subdirectory, -h makes it human-readable, sort -rh sorts by size descending (largest first), and head -20 limits output to the top 20 results.
Scan a specific directory and summarise subdirectories:
du -sh /home/*/
On a cPanel server, this gives you a quick per-account breakdown — useful for identifying which user account is consuming the most space.
Drill deeper — find the largest directories under /var:
du -h --max-depth=2 /var | sort -rh | head -20
/var is where logs, mail queues, and database files typically live. On busy servers it’s often where runaway disk usage hides.
📝 Note: du requires read access to the directories it scans. Always run it as root or with sudo when scanning system directories, or you’ll get a lot of “Permission denied” errors that skew your results.
Step 4: Find Large Files Directly
Sometimes a single massive log file or a forgotten database dump is the whole problem. This command finds every file over 500MB on the filesystem:
find / -xdev -type f -size +500M -exec ls -lh {} ; 2>/dev/null | sort -k5 -rh
The -xdev flag tells find not to cross filesystem boundaries — without it, on servers with multiple mounts, you’ll get duplicate results and the command runs much slower. The 2>/dev/null suppresses permission-denied errors so the output stays clean.
Adjust +500M to whatever threshold makes sense for your situation — +1G for dedicated servers, +100M on smaller plans.
Step 5: Check for Deleted Files Still Holding Space
This is the gotcha that experienced sysadmins know and beginners don’t. When a process has a file open and you delete that file, Linux unlinks it from the directory — but the disk space isn’t released until the process closes its file handle. df will still show the space as used, but du won’t find the file because it’s no longer linked to any directory.
On hosting servers, this happens constantly with log files that are deleted while Apache, Nginx, or MySQL is still writing to them.
To find these ghost files:
lsof +L1 2>/dev/null | grep -i deleted
+L1 shows files with a link count below 1 — meaning they’ve been unlinked (deleted) but are still open. The fix is to either restart the process holding the file open, or truncate the file in place instead of deleting it:
> /path/to/the/deleted-but-open.log
That empties the file without closing the file handle, so the process keeps running and the disk space is freed immediately. I’d recommend this over restarting services during production hours.
Common Issues and Troubleshooting
df and du Report Very Different Numbers
If df -h shows 90% used but du -sh / only accounts for 60% of that space, deleted-but-open files are almost always the reason. Run lsof +L1 as described above. Restarting the offending service (or truncating the open file) will reconcile the numbers and free the space.
“No space left on device” but df Shows Free Space
You’ve hit the inode limit. Run df -i to confirm. The most common cause on web hosting servers is a mail queue full of small files, or a WordPress install that has accumulated thousands of tiny cache files. Find the directory with the most files:
find /home -xdev -type f | cut -d/ -f1-4 | sort | uniq -c | sort -rn | head -20
Clear the cache or flush the mail queue, and your inode count will drop immediately.
du Takes Forever or Hangs
Running du on a directory with millions of files (like a Maildir mail store or a bloated cache directory) can take many minutes. Use --max-depth to limit recursion, and always add 2>/dev/null to suppress permission errors that slow output. If you need something faster for a quick check, ncdu is a great alternative — install it with apt install ncdu or yum install ncdu and it gives you an interactive, browsable view of disk usage.
Permission Denied Errors When Running du
You’re running du as a non-root user and hitting directories you don’t own. Add sudo before the command, or redirect stderr to suppress the noise: du -sh /var/* 2>/dev/null. If you’re on a shared hosting plan without SSH root access, your hosting control panel (cPanel, Plesk) has a built-in disk usage tool — check the “Disk Usage” section in the main dashboard.
Disk Fills Up Again Immediately After Clearing Space
Something is actively writing to disk at a high rate. The most common culprits on hosting servers are runaway PHP error logs, MySQL binary logs that aren’t being rotated, or an application stuck in an error loop generating log entries. To watch which files are growing in real time:
watch -n 5 'du -sh /var/log/* 2>/dev/null | sort -rh | head -10'
This refreshes every 5 seconds and shows you the largest items in /var/log — adjust the path to wherever you suspect the problem is.
Further Reading
If you’re consistently running low on disk space and your workload is growing, it may be time to look at upgrading your storage. Our VPS SSD Hosting plans are built on NVMe SSD storage and include easy vertical scaling — you can increase disk allocation without migrating your server. Plans start from $5.83/mo and are available across our North American, European, and Australian datacentres.
Frequently Asked Questions
What is the difference between df and du in Linux?
df reports how full your mounted filesystems are — it reads data from the filesystem metadata and is very fast. du actually walks through directory trees and adds up file sizes. They measure slightly different things, which is why their numbers don’t always match exactly. Use df to spot a disk space problem, then use du to find where it’s coming from.
How do I find which directory is using the most disk space on Linux?
Run du -sh /* 2>/dev/null | sort -rh | head -20 from the root to get a top-level breakdown, then drill into whichever directory is largest. Repeating that process a few levels deep will pinpoint the problem directory in a couple of minutes. On cPanel servers, du -sh /home/*/ gives you a quick per-account summary.
Why does my Linux server say 'no space left on device' when df shows free space?
You’ve most likely run out of inodes, not raw disk space. Check with df -i — if any partition shows IUse% at or near 100%, that’s your problem. It’s common on servers with lots of small files, like mail servers or WordPress sites with large cache directories. Clearing those small files will free up inodes.
How do I check disk usage for a specific user on a cPanel server?
Run du -sh /home/username/ replacing username with the actual cPanel account name. For a breakdown of what’s inside that account, use du -sh /home/username/* | sort -rh. You can also see per-account disk usage in WHM under Account Information > View Bandwidth Usage, or in cPanel itself under Files > Disk Usage.
Is it safe to delete files to free up disk space on a Linux server?
It depends on what you’re deleting. Log files in /var/log are generally safe to clear (truncate rather than delete if a service is running). Old backups, temporary files in /tmp, and application cache directories are usually safe too. Never delete files in /bin, /lib, /usr, or /etc without knowing exactly what they are — removing system files can make your server unbootable.