Linux Memory Reporting

LinuxLinuxBeginner
Practice Now

Introduction

In the era of ancient Egypt, the grand pyramids stood as monumental feats, containing untold secrets and treasures. While historians had long studied these mysterious structures, a particular group of Egyptian scholars, known as the Keepers of the Kemet Code, were more interested in the metaphysical properties that the pyramids possessed -- specifically, an ability to channel cosmic energy and memory of the universe.

As a new member of the Keepers, you are tasked with a unique challenge that mirrors the careful balance maintained within the pyramids: to master the art of memory reporting within Linux systems. Just as a pyramid's stability depends on every stoneโ€™s perfect placement, a Linux system's performance hinges on the precise allocation and usage of its memory resources.

Your goal is to navigate the labyrinth of Linux memory reporting and unveil its secrets using the free command. Your journey will not only test your ability to uncover information about the system's memory but also to interpret and utilize this data to maintain the equilibrium of your digital pyramid - the Linux machine.


Skills Graph

%%%%{init: {'theme':'neutral'}}%%%% flowchart RL linux(("`Linux`")) -.-> linux/SystemInformationandMonitoringGroup(["`System Information and Monitoring`"]) linux/SystemInformationandMonitoringGroup -.-> linux/free("`Memory Reporting`") subgraph Lab Skills linux/free -.-> lab-271285{{"`Linux Memory Reporting`"}} end

Exploring the free Command

In this step, you delve into the fundamental tool for memory reporting in Linux โ€“ the free command. You will explore how to use the command to check the amount of free and used memory in the system. By running the free command, you can determine the system's memory status, which is crucial for maintaining system stability.

Start by opening your terminal in the default workspace at /home/labex/project and execute the following command:

free -h

This command provides a readable output, displaying memory statistics in human-friendly numbers with appropriate units (e.g., Mi, Gi). Here's what the output might look like:

               total        used        free      shared  buff/cache   available
Mem:           7.8Gi       2.9Gi       1.0Gi        23Mi       3.9Gi       4.6Gi
Swap:             0B          0B          0B

Create a document named memory_stats.txt in the ~/project directory to record your findings:

touch ~/project/memory_stats.txt

Now redirect the output of the free command to memory_stats.txt:

free -h > ~/project/memory_stats.txt

Understanding Memory Output

Understanding the output of the free command is crucial. This step focuses on deciphering the various columns like 'total', 'used', 'free', 'shared', 'buff/cache', and 'available'.

Open the memory_stats.txt file using a text editor, or by using the cat command:

cat ~/project/memory_stats.txt

Each column in the output has significance:

  • total: Total installed memory (RAM) on the system.
  • used: Memory currently used by the system.
  • free: Memory that is not being used for any purpose.
  • shared: Memory used mostly by the tmpfs (Temporary filesystems and shared memory).
  • buff/cache: Cached and buffered memory used by the kernel.
  • available: Estimate of how much memory is available for starting new applications, without swapping.

Write a brief report in memory_report.txt about each column's purpose and what the numbers signify:

Create a brief report:

touch ~/project/memory_report.txt

The content of the brief report should be as follows:

total:
used:
free:
shared:
buff/cache:
available:

Include the information mentioned above and save your report.

Summary

In this lab, we embraced the scenario of ancient Egyptian scholars to explore the free command's role in reporting memory usage on a Linux system. We began by generating and recording the system's memory output, then proceeded to create a detailed report understanding the crucial components of Linux memory management.

Through hands-on experience, we learned how to use and interpret the free command output, analogous to the Keepers decoding the language of the pyramids. This lab not only enhanced our technical skills but also provided an imaginative approach to perceiving Linux system administration as an art paralleled by the ancient world's mysteries.

Other Linux Tutorials you may like