How to Check Disk Usage in Linux


 Introduction

Monitoring disk usage is important for system administration. Linux provides commands to check how much space is used and where it is consumed.


Step 1: Check Overall Disk Usage with df


df -h


➡️ Displays disk space in human-readable format (GB/MB).


Step 2: Check Directory Size with du


du -sh /path


➡️ Example:


du -sh /var/log


This shows the total size of /var/log.


Step 3: Find Top Space-Consuming Directories


du -sh * | sort -h


➡️ Useful to see which folders take the most space inside the current directory.


Step 4: Combine with ncdu (Optional)


ncdu /


➡️ A more interactive tool (needs to be installed first: sudo apt install ncdu or sudo yum install ncdu).


Conclusion

By using df, du, and ncdu, you can easily monitor and analyze disk usage in Linux to prevent running out of space.

Comments