Get Total RAM Size on Linux

Get Total RAM Size on Linux

Determining the total RAM size on a Linux system is a fundamental task for understanding the system's memory capabilities and optimizing performance. RAM is a vital component of any computer, as it directly impacts the system's ability to handle and process data effectively. Knowing the total RAM size helps in various aspects of system management, such as allocating resources, optimizing application performance, and diagnosing potential issues related to memory usage. This tutorial shows how to get total RAM size on Linux.

The following command can be used to get the total RAM size of the Linux computer in gigabytes (GB):

sudo dmidecode -t 19 | awk -F': |GB' '/Range Size/{print $2}'

Let's break down the command step by step:

  • dmidecode - is a tool on Linux used to retrieve hardware information from the system's BIOS.
  • -t 19 - this option specifies the type of data to be displayed. In this case, type 19 is for memory devices.
  • awk - is a text processing tool on Linux used for pattern scanning and processing.
  • -F': |GB' - this option sets the field separator for awk. It defines the delimiter as either colon followed by a space or GB. This means awk will treat either of these as a field separator, making it easier to extract specific information.
  • /Range Size/ - instructs awk to find lines that contain the phrase Range Size.
  • {print $2} - this is the action to be performed when the pattern is matched. It instructs awk to print the second field, which contains the total RAM size in gigabytes (GB).

Leave a Comment

Cancel reply

Your email address will not be published.