Easy Steps To Display Disk Space on AlmaLinux 8/9 – OrcaCore

Posted on

Easy Steps To Display Disk Space on AlmaLinux 8/9 – OrcaCore

This article aims to guide you through the process of Check or Display Disk Space on AlmaLinux 8/9. The Linux operating system, while sometimes perceived as technical, grants users significant control over their system. Managing disk space on Linux servers is paramount. Running out of disk space can lead to website crashes and other critical system failures.

There are several methods to monitor disk space in Linux. One option is to use a third-party application that provides a graphical representation of disk usage. However, the command line, accessed through the Linux Terminal, offers powerful tools like df (disk free) and du (disk usage) for detailed analysis. This guide, presented by Orcacore, will walk you through these command-line utilities.

Before proceeding, ensure you’re logged into your server as either a root user or a non-root user with sudo privileges. If you need help with initial server setup, refer to these Orcacore guides:

Initial Server Setup with AlmaLinux 9

Initial Server Setup with AlmaLinux 8

Check Disk Space Linux with df Command on AlmaLinux

The df command provides a snapshot of available disk space on the filesystem, displaying information for each filesystem specified as an argument.

The simplest way to use it is by typing:

df

This will produce output similar to the following:

Check Disk Space Linux with df Command

For a more human-readable output, the -h option is recommended:

df -h

This will display disk space in units like KB, MB, and GB, making it easier to interpret.

Check File System Type on AlmaLinux

To determine the file system type of your partitions, use the df command with the -T option:

df -T

This command will display the filesystem type alongside other disk space information.

You can also filter the output to display information only about a specific file system type, such as ext4:

df -t ext4

ext4 is commonly the default file system for numerous Linux distributions.

Check Disk Space Linux with du command on AlmaLinux

The du (disk usage) command is used to determine the amount of disk space used by files and directories.

To check the disk space usage of the current directory, use:

du
**<mark>Output</mark>**
32      .

To view the information in a human-readable format, use the -h option on your AlmaLinux system:

du -h
**<mark>Output</mark>**
32K     .

To display the total disk space usage of a specific directory, combine the -h and -s options:

du -hs /var/log
**<mark>Output</mark>**
4.5M    /var/log

You can also sort the output of the du command by size using the sort command:

du -h | sort -rn
**<mark>Output</mark>**
32K     .

Conclusion

As emphasized earlier, effective disk space management is crucial for Linux servers. Insufficient disk space can lead to server instability and website downtime. You have now learned how to Display or Check Disk Space on AlmaLinux using command-line tools.

Hopefully, you found this guide helpful. You might also be interested in these related articles:

Install Visual Studio Code on AlmaLinux 8

Install Docker Compose on AlmaLinux 8

Alternative Methods to Display Disk Space on AlmaLinux

While df and du are powerful tools, here are two alternative methods for check disk space Linux offering different perspectives and functionalities:

1. Using lsblk with the -d and -o options

The lsblk command is primarily used to list block devices. However, with specific options, it can provide a concise overview of disk space usage for block devices.

  • -d : Displays only the device, not partitions.
  • -o : Allows you to specify the output columns.

This command allows you to Check or Display Disk Space on AlmaLinux concisely.

lsblk -d -o NAME,SIZE,FSTYPE,MOUNTPOINT

Explanation:

  • NAME: Displays the name of the block device (e.g., sda, sdb).
  • SIZE: Displays the size of the block device.
  • FSTYPE: Displays the filesystem type.
  • MOUNTPOINT: Shows where the device is mounted.

Example Output:

NAME   SIZE FSTYPE MOUNTPOINT
sda  200G              
sdb  100G ext4   /data

This command provides a quick overview of the disks, their sizes, filesystem types, and mount points. It’s particularly useful for identifying disks that might be nearing capacity. The lsblk command is a versatile tool that you can use to check disk space Linux and more.

2. Using ncdu (NCurses Disk Usage)

ncdu is a curses-based disk usage analyzer. It provides an interactive, visual way to explore disk space usage, allowing you to drill down into directories and identify large files consuming the most space.

Installation (if not already installed):

sudo dnf install ncdu

Usage:

To analyze the disk usage of the current directory, simply run:

ncdu

To analyze a specific directory, specify the directory path:

ncdu /var/log

Explanation:

ncdu will open an interactive interface in your terminal. You can use the arrow keys to navigate through directories, and it displays the size of each file and directory in a human-readable format. Press ‘q’ to quit.

Benefits of ncdu:

  • Interactive Exploration: Allows you to visually navigate and drill down into directories.
  • Easy Identification of Large Files: Quickly identifies files and directories consuming the most disk space.
  • User-Friendly Interface: Provides a clear and intuitive way to understand disk usage.

ncdu is a valuable tool for diagnosing disk space issues and identifying areas where you can reclaim space. These alternative methods are powerful additions to your AlmaLinux toolkit.