Disk Usage and Monitoring in Linux


 Introduction

Monitoring disk usage is critical to prevent servers from running out of space. Linux provides simple yet powerful commands for tracking disk consumption.


Step 1: Check Overall Disk Usage


df -h


➡️ Shows disk usage of mounted file systems in human-readable format.


Step 2: Check Directory Size


du -sh /path/to/directory


➡️ Displays total size of a specific directory.


Step 3: Find Largest Files/Directories


du -ah /path | sort -rh | head -n 10


➡️ Lists the 10 largest items under a directory.


Step 4: Monitor Disk Usage in Real Time


watch -n 5 df -h


➡️ Updates disk usage every 5 seconds.


Step 5: Check Inodes Usage


df -i


➡️ Useful when disk space seems fine but you can’t create new files.


Conclusion

Monitoring disk usage helps avoid downtime and ensures smooth system performance. Next, we’ll learn about network troubleshooting commands.

Comments