Skip to content

Click on each book below to review & buy on Amazon.

As an Amazon Associate, I earn from qualifying purchases.


CompTIA Linux+ XK0-005 - 1.3 - Monitor Storage Space & Disk Usage

In the Comptia Linux+ exam, it is important to understand how to monitor storage space and disk usage on a Linux system. By monitoring disk usage, you can keep track of available storage, identify areas of high usage, and take necessary actions to optimize disk space. In this guide, we will explore two commonly used commands for monitoring storage space and disk usage: df and du.

df - Display Filesystem Usage

The df command is used to display the amount of disk space used and available on file systems mounted on the Linux system. It provides an overview of the total disk space, used space, available space, and the mount point of each file system.

The df command can be run without options to show all disks and space usage or a partition can be specified.

# show all partitions
df -h

# show just the /var partition
df -h /var

Output would look similar to:

Filesystem     1K-blocks   Used Available Use% Mounted on
/dev/sda1        1048576 678912    369664  65% /
/dev/sdb1       20971520 524288  20447232   3% /mnt/data

Some commonly used options are:

  • -h or --human-readable: Display sizes in human-readable format.
  • -T or --print-type: Display file system type.
  • -i or --inodes: Display inode information.

du - Estimate File Space Usage

The du command is used to estimate file space usage of directories and files on a Linux system. It helps you identify the disk space consumed by individual directories or files, allowing you to identify large files or directories that may be consuming excessive storage.

The du command can run without any options to show disk usage in the current directory or a directory or file can be specified.

# show current directory disk usage
du -h

# show /var/log directory disk usage
du -h /var/log

Output would look similar to:

248K    /var/log/sssd
36K     /var/log/tuned
64K     /var/log/rhsm
2.5M    /var/log/audit
7.7M    /var/log/anaconda
12K     /var/log/cups
15M     /var/log

Some commonly used options are:

  • -h or --human-readable: Display sizes in human-readable format.
  • -s or --summarize: Display only the total size.
  • -c or --total: Display a grand total of all sizes.

Conclusion

Monitoring storage space and disk usage is essential for maintaining a healthy Linux system and ensuring efficient resource utilization. The df and du commands provide valuable insights into file system usage and help you identify areas where disk space is being consumed.

With the df command, you can get an overview of the overall disk space utilization, including the total size, used space, available space, and mount points of file systems. This information allows you to quickly assess the storage situation and identify if any file systems are running low on space.

On the other hand, the du command enables you to estimate the file space usage of specific directories and files. It helps you drill down into individual directories and identify large files or directories that may be taking up significant disk space. This can be particularly useful when you want to identify areas for cleanup or optimize storage allocation.

By regularly using these commands and incorporating them into your system monitoring practices, you can proactively manage disk space, prevent potential issues related to storage limitations, and ensure smooth system performance.


Support DTV Linux

Click on each book below to review & buy on Amazon. As an Amazon Associate, I earn from qualifying purchases.

NordVPN ®: Elevate your online privacy and security. Grab our Special Offer to safeguard your data on public Wi-Fi and secure your devices. I may earn a commission on purchases made through this link.