How to Monitor Disk Usage in Linux
Introduction
Monitoring disk usage is essential for keeping a Linux system healthy. Running out of space can cause applications to crash or even prevent the system from working. Here are some simple commands to check and monitor disk usage.
Step 1: Check Disk Space with df
df -h
➡️ The -h option shows disk usage in a human-readable format (GB/MB).
Step 2: Check Directory Size with du
du -sh /path/to/directory
➡️ This shows the total size of a specific directory. Replace /path/to/directory with your target folder.
Step 3: Find Large Files
find / -type f -size +500M
➡️ This finds all files larger than 500 MB on your system.
Step 4: Use ncdu for Interactive Monitoring
sudo apt install ncdu # Debian/Ubuntu
sudo yum install ncdu # CentOS/RHEL
➡️ Run it with:
ncdu /
This gives you an interactive interface to explore disk usage.
Conclusion
By using tools like df, du, and ncdu, you can easily monitor disk usage, identify space hogs, and keep your Linux system running smoothly.

Comments
Post a Comment