Linux Essential Disk Space Usage Checks Commands

A Guide for System Administrators 

Introduction:

As a system admin in Unix or Linux, it's key to know how to spot where most disk space is used. Linux has handy commands for this. They're crucial for keeping your system in top shape.

Key features of Linux disk space commands:

ls -lhS 🔍

Explanation: This command lists files, focusing on large sizes first. It's great for quickly identifying the biggest files in a directory.

du -sh  📁

Explanation: Shows the total size of a directory and its contents, providing a summary of space usage.

du -h | sort -hr | head 📊

Explanation: Ranks directories by their size, giving you a clear view of which directories are using the most space.

find -type f | du -h | sort -rh | head -n 10 📜🔝

Explanation: Locates and lists the top 10 largest files, helping in pinpointing major space consumers.

find -type d | du -h | sort -rh | head -n 10 📂🔝

Explanation: Identifies the top 10 largest directories, crucial for managing and optimizing disk space usage.

|-----------------------------|---------------------------------------------------------------------------|

| Title                       | Command                                                                   |

|-----------------------------|---------------------------------------------------------------------------|

| Human-Readable Sort by Size | # ls -lhS /home/centos                                                    |

|-----------------------------|---------------------------------------------------------------------------|

| Total Directory Size        | # du -sh /home/centos                                                     |

|-----------------------------|---------------------------------------------------------------------------|

| Sort Directories by Size    | # du -h /home/centos | sort -hr | head                                    |

|-----------------------------|---------------------------------------------------------------------------|

| Top 10 Largest Files        | # find /home/centos -type f -exec du -h {} + | sort -rh | head -n 10      |

|-----------------------------|---------------------------------------------------------------------------|

| Top 10 Largest Directories  | # find /home/centos -type d -exec du -h {} + | sort -rh | head -n 10      |

|-----------------------------|---------------------------------------------------------------------------|

Conclusion:

In essence, for Unix and Linux systems, adept disk space monitoring is crucial. It ensures efficient use and system reliability. 

With simple commands, admins can prevent space-related issues. This routine upkeep is the backbone of system health.

Follow Us for More Updates and Articles:

If you enjoyed this article, follow us on social media platforms such as Twitter, Facebook, subscribe to our channel, and connect with us on LinkedIn.

YouTubeLinkedInTwitterFacebook