Linux Disk Space Checks for Website Owners: df, du, and Inodes

A website can slow down or fail when its server runs short of disk space. Logs, backups, uploads, and application caches can grow quietly until a full file system prevents new files from being written. A few read-only Linux commands help you spot the problem before it becomes an outage.

Start With the File System: df

Run df -h to see used and available space on mounted file systems in human-readable units. Look at the Use% column and, more importantly, identify the mount point that holds your website, database, or logs. A server can have plenty of free space on one volume while another is nearly full.

If you know the website directory, df -h /var/www shows the file system containing that path. Replace /var/www with the real location on your server. This is more useful than assuming that every site lives on the root volume. Our guide to essential Linux commands provides a broader starting point for working at the terminal.

Find the Large Directories: du

Once you know which file system is filling up, use du to estimate where its space is going. For example, du -h --max-depth=1 /var/www shows approximate sizes of directories directly beneath /var/www. You can repeat the command inside a large directory to narrow the search.

du -sh /var/log gives a single summary for the log directory. You may need appropriate permissions to see everything. Also remember that du describes the files it can traverse, while df reports space at the file-system level; their numbers need not match exactly. Avoid treating a large directory as safe to delete until you understand what it contains.

Check Inodes When Space Looks Available

A file system can refuse new files even when df -h shows free capacity. On file systems with a finite inode pool, a huge number of small files can exhaust the available inodes. Run df -i and check the IUse% column. Session files, caches, or temporary files may be responsible, but verify their purpose before removing anything.

If the site is already having trouble, review application and server logs alongside disk metrics. Our article on Linux log files for website troubleshooting explains how to locate useful error messages.

Clean Up Safely and Prevent a Repeat

Begin with known, disposable material: expired backups, obsolete deployment archives, or application caches that the application itself can rebuild. Check retention requirements before deleting logs or backups. Never remove unfamiliar system files simply because they look large, and do not run a broad deletion command against a production directory.

After cleanup, run df -h and df -i again to confirm that capacity has recovered. Then set alerts for both disk usage and inode usage, and review the growth trend rather than waiting for a full-volume warning. If backups are consuming the same volume as the live site, consider a separate destination and a clear retention policy.

For precise command behaviour and options, consult the GNU Coreutils file-space usage documentation. A short, regular check with df and du can turn an unexpected outage into routine maintenance.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *