DEV Community

Prince Maurya
Prince Maurya

Posted on AI-assisted

Quick tip: How to find and free up disk space in Linux

A full disk is a common reason for random service crashes in Linux. Here is a quick 3-step checklist to find and fix it:

  1. Check disk usage Find which partition is full:
df -PhT
Enter fullscreen mode Exit fullscreen mode
  1. Spot the largest folders Locate the top 10 space-consuming directories:
sudo du -sh /* 2>/dev/null | sort -hr | head -n 10
Enter fullscreen mode Exit fullscreen mode
  1. Quick cleanup commands Clear log files:
sudo truncate -s 0 /var/log/syslog
Enter fullscreen mode Exit fullscreen mode

Clear package cache:

sudo apt clean
Enter fullscreen mode Exit fullscreen mode

Check open deleted files:

sudo lsof +L1
Enter fullscreen mode Exit fullscreen mode

What’s your go-to command when storage runs out? Let me know in the comments!

Top comments (0)