Debugging Disk Space Issues on Linux
Some handy commands for quickly checking whats eating up storage space on linux vps(in my case it was poorly configured github action runners and chonky npm and nextjs cache) Get a High-Level Overview with df The df command (Disk Free) gives you a summary of available and used disk space on all mounted filesystems. To get a human-readable output: df -h What the flags mean: -h: Stands for human-readable. This makes the output display sizes in KB, MB, or GB instead of just raw block counts. Sample output: Filesystem Size Used Avail Use% Mounted on /dev/sda1 50G 45G 1.5G 97% / tmpfs 2.0G 0 2.0G 0% /dev/shm /dev/sdb1 100G 85G 10G 90% /home Drill Down with du, sort, and head Once you know which filesystem is full (say /), you need to find which directories inside it are using the most space. This is where du (Disk Usage), sort, and head come into play. sudo du -ahx / | sort -rh | head -10 sudo: Required to access system directories and get accurate readings. du: Stands for Disk Usage. a: Lists both files and directories (not just directories). h: Again, human-readable. x: Restricts the command to a single filesystem, preventing it from traversing into mounted volumes like /proc, /mnt, or /boot. / The directory you're scanning. Replace this with any path like /var, /home, etc., to narrow your search. sort -rh: r: Sorts in reverse order (largest files first). h: Sorts human-readable sizes correctly (so 1G is more than 500M). head -10: Displays only the top 10 largest entries. example output 2.5G /var/log/journal 1.8G /usr/lib 1.2G /var/cache 900M /home/user/videos 700M /var/log/syslog.1 This tells you exactly where your storage is being used. Now you can clean things up with precision.

Some handy commands for quickly checking whats eating up storage space on linux vps(in my case it was poorly configured github action runners and chonky npm and nextjs cache)
Get a High-Level Overview with df
The df command (Disk Free) gives you a summary of available and used disk space on all mounted filesystems. To get a human-readable output:
df -h
What the flags mean:
-h: Stands for human-readable. This makes the output display sizes in KB, MB, or GB instead of just raw block counts.
Sample output:
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 50G 45G 1.5G 97% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
/dev/sdb1 100G 85G 10G 90% /home
Drill Down with du, sort, and head
Once you know which filesystem is full (say /), you need to find which directories inside it are using the most space. This is where du (Disk Usage), sort, and head come into play.
sudo du -ahx / | sort -rh | head -10
sudo: Required to access system directories and get accurate readings.
du: Stands for Disk Usage.
a: Lists both files and directories (not just directories).
h: Again, human-readable.
x: Restricts the command to a single filesystem, preventing it from traversing into mounted volumes like /proc, /mnt, or /boot.
/
The directory you're scanning. Replace this with any path like /var
, /home
, etc., to narrow your search.
sort -rh:
r: Sorts in reverse order (largest files first).
h: Sorts human-readable sizes correctly (so 1G is more than 500M).
head -10: Displays only the top 10 largest entries.
example output
2.5G /var/log/journal
1.8G /usr/lib
1.2G /var/cache
900M /home/user/videos
700M /var/log/syslog.1
This tells you exactly where your storage is being used. Now you can clean things up with precision.