RAM, short for Random Access Memory, can be considered the workspace of your computer system. Whenever you open a file for viewing or editing, your system creates a temporary instance of that file in your RAM so that you can work on it. When you save the file, your system copies it to a more stable and non-volatile space( hardware) called the Read Only Memory. Also, when you run a program, your operating system and RAM are the medium on which it is run. A good balance of adequately sized and fast RAM is your answer when looking for a high-performance computing system.
While using Ubuntu, we come across many scenarios where RAM is a huge consideration. We want to know how much RAM is installed on our system, how much of it we can use, is our RAM free of errors, and much more.
In this article, we will explain the following things you can do about your installed RAM through the Ubuntu command line:
- Check for Installed, Used, and Available RAM
- Check the Type and Speed of your installed RAM
- Test your installed RAM for errors
We have run the command and procedures mentioned in this article on a Ubuntu 22.04 LTS system.
Note: We will use the Ubuntu command line, the Terminal, to explain the above-mentioned tasks. You can open the Terminal application through the Ubuntu Application launcher search bar or the Ctrl+Alt+T shortcut.
How to check the Installed, Used, and Available RAM
The simplest way to check for memory stats on your Ubuntu is through the free command:
This is how you use the free command:
This command is used to check memory and swap utilization on your system in a few lines. Without any switch, the displayed output is printed in kilobytes.
However, a better approach is to use the -h switch so that the free command displays the memory and swap utilization in the nearest possible-3 digit format.
$ free -h
The “Mem” part of the output gives you information about the RAM on your system. The total column gives you the total GBs of RAM installed on your system. The used and available columns indicate the RAM used by your system and the GBs available for use, respectively.
How to check the Type and Speed of RAM
Before explaining how to check the Type and Speed of your RAM, let us first define what they both mean:
- Type: RAM these days comes in many profiles based on the data and transfer rates. These include the older SDRAM(Synchronous dynamic RAM), the DDR1(DDR SDRAM), DDR2, DDR3, and the modern DDR4. For portable systems, RAM comes in DRAM and SDRAM types.
- Speed: When we talk about the RAM speed in MHz or GHz, we consider the clock cycles. A cycle means a single read-and-write session. The speed of the RAM means how many cycles per second it can perform. A 3200 MHz RAM can perform 3200 cycles( read/write sessions) in one second.
You can use the dmidecode command run via sudo to check the type of your RAM. First we take care that the commands are installed:
$ sudo apt install dmidecode less
Then run the dmidecode command:
$ sudo dmidecode --type memory | less
The system will ask you for the password of the sudo user and then display the following information:
Scroll down and spot the Type of RAM in the output, as highlighted above. As you can see, I have DDR3 installed on my laptop.
Through the same command, you can also view the Clock Speed of your RAM:
The above output shows that I have 1333 MHz of RAM installed on my system.
You can use the ‘q’ key to quit this output.
How to Test RAM for errors through the MemTester utility
Since RAM is a fragile device, its semiconductors may sometimes face breakage. This might affect the performance of your overall RAM. You can make use of the MemTester to test your RAM for errors.
To install this utility, open your Terminal application and enter the following command to first update your system’s repository index with that of the Internet repositories. This ensures that the latest available version of a software can be installed on your system.
$ sudo apt update
Then, use the following apt-get command to install memtester. If you are unsure if memtester is already installed, you can also check it in the package list first, as shown here.
$ sudo apt install memtester
This is the Usage of the memtester command:
$ memtester [-p physaddrbase [-d device]] <mem>[B|K|M|G] [loops]
The following command will check 200 MBs of RAM space in two iterations:
$ sudo memtester 200M 2
This is what the test output looks like.
The output indicated that I do not have any errors in my RAM. Lucky much for how roughly I sometimes use my Laptop.
There is, however, one limitation of this command: you can only scan RAM up to the size of free RAM on your system. The memtest86+ utility at boot GRUB menu is what you can use to test your RAM thoroughly.
So these were a few commands through which you could know all about the RAM installed on your Ubuntu system. You also learned how to use the memtest utility to ensure that your RAM works optimally.