After connecting to your Linux server via SSH, you have several commands available to check disk space usage, both at the filesystem level and for individual directories and files. This guide covers the most useful ones.
On shared or reseller hosting? You can check your disk usage without SSH by logging in to cPanel and going to Files → Disk Usage. The commands in this guide are for VPS and dedicated server customers with SSH access.
Checking overall disk space, df
The df command (disk free) shows disk space usage for each mounted filesystem on the server.
Human-readable output (recommended)
df -h
The -h flag formats sizes in human-readable units (GB, MB) rather than raw bytes. Example output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 18G 30G 38% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/sda2 200G 145G 45G 73% /home
The key columns to read:
| Column | What it means |
|---|---|
| Size | Total capacity of the filesystem |
| Used | Space currently in use |
| Avail | Space available for use |
| Use% | Percentage of space used. If this is above 85%, you should investigate what is consuming space |
| Mounted on | Where the filesystem is mounted. /home is typically where website and user files live |
Show disk usage in kilobytes
df -k
Show only a specific directory's filesystem
df -h /home
Check inode usage
Inodes represent the number of files and directories. A server can run out of inodes even if there is still disk space available, causing errors when creating new files:
df -i
If the IUse% column is near 100%, you have too many files. See the section on finding and clearing large numbers of files below.
Finding what is using space, du
The du command (disk usage) shows how much space individual directories and files are consuming. This is how you find out what is filling up your disk.
Check total size of a specific directory
du -sh /home/username
The -s flag gives a summary total rather than listing every subdirectory, and -h makes it human-readable.
List the largest subdirectories inside a directory
du -h --max-depth=1 /home/username | sort -rh
This shows the size of each immediate subdirectory inside /home/username, sorted largest first. Useful for quickly identifying which subfolder is consuming the most space.
Find the top 10 largest directories on the whole server
du -h / --max-depth=3 2>/dev/null | sort -rh | head -10
Find the largest individual files in a directory
find /home/username -type f -printf '%s %p\n' | sort -rn | head -20
This lists the 20 largest files under /home/username, sorted by size in bytes. Useful for tracking down large log files, database dumps, or backup archives left on the server.
Find files larger than a specific size
find /home/username -type f -size +100M
This finds all files over 100MB. Change 100M to any size you want to filter by (e.g. 500M for 500MB, 1G for 1GB).
Common causes of disk space issues on Linux servers
If your disk is filling up unexpectedly, check these common culprits first:
| Cause | Where to look | How to fix |
|---|---|---|
| Log files | /var/log/ |
Compress or rotate old logs. Check du -sh /var/log/* to identify large ones |
| MySQL/database data | /var/lib/mysql/ |
Export and optimise large databases. Remove old databases that are no longer needed |
| Backup archives left on the server | /home/username/ or /root/ |
Download backups locally then remove them from the server |
| Email stored on the server | /home/username/mail/ |
Encourage users to empty trash and spam folders, or reduce email retention periods |
| WordPress cache files | /home/username/public_html/wp-content/cache/ |
Clear the cache via your caching plugin dashboard, or delete the cache folder contents |
| PHP session files | /tmp/ or /var/lib/php/sessions/ |
Old session files can accumulate. Safe to delete files older than a day: find /tmp -name 'sess_*' -mtime +1 -delete |
| Core dump files | / root or application directories |
Find with find / -name "core" -type f 2>/dev/null and remove if not needed for debugging |
Monitoring disk space over time
To watch disk space change in real time (useful during a file transfer or cleanup):
watch -n 5 df -h
This refreshes the df -h output every 5 seconds. Press Ctrl+C to exit.
Quick reference
| Command | What it does |
|---|---|
df -h |
Show all filesystem usage in human-readable format |
df -i |
Show inode usage across filesystems |
du -sh /path |
Show total size of a specific directory |
du -h --max-depth=1 /path | sort -rh |
List subdirectories by size, largest first |
find /path -type f -size +100M |
Find files larger than 100MB |
watch -n 5 df -h |
Monitor disk usage in real time |