How to Check VPS Disk Usage and Remove Unnecessary Files

The first step is to figure out what exactly is consuming space. Linux provides built-in tools for this task.

The simplest command is:

df -h

It displays the total, used, and available disk space across all mounted partitions in a human-readable format.

Example output:

Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2       441G   25G  393G   6% /
/dev/sda1       300M  3.5M  296M   2% /boot/efi
tmpfs           7.8G     0  7.8G   0% /dev/shm
...

This gives you a clear overview of your server’s storage usage.

What You Can Safely Remove

Once you identify the heaviest directories, you can start cleaning up. Common space hogs include:

  • Log files — they often grow large, especially in /var/log. To remove logs older than 30 days: find /var/log -type f -name "*.log" -mtime +30 -exec rm {} \;
  • Old backups — archives in .tar.gz, .zip, or similar formats that are no longer needed.
  • Cache — for example, the package cache in Debian/Ubuntu (/var/cache/apt/archives). It can be cleared with: sudo apt-get clean
  • Build and temporary files — leftovers from compilation in src, build, and tmp directories.

Performing these cleanups regularly ensures your VPS remains stable and doesn’t run out of space unexpectedly.

Leave a Reply 0

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