ubuntu check ram

Checking the amount of installed RAM and monitoring how much is actually being used is a fundamental task that anyone new to Ubuntu should learn.

Or if you’re encountering random crashes, file corruption, or similar problems, you may need to test the RAM for faults. We’ll cover all such topics in this article.

Check RAM Size and Speed

There are numerous ways to get RAM stats on Ubuntu. If you only need to check the free and used memory, the free command can do this quickly. Use the mega flag to display the output in megabytes.

free --mega

If you want more detailed info on the RAM (type, frequency, size, form factor, etc.), you can use dmidecode instead.

sudo dmidecode --type memory

Another alternative is the vmstat command which displays various system resource stats. You can use the -s flag to display mainly memory stats. 

vmstat -s

You can also read the /proc/meminfo file to get memory stats such as used/available memory, cache, swap space, etc.

cat /proc/meminfo

Monitor RAM Usage

Most of the commands shown earlier display RAM usage stats. But those were one-off values. If you want to monitor RAM usage over time with updating data, you can use the GNOME System Monitor or even better, CLI tools like top and htop.

Test for Faulty RAM

One complaint we often see from new Ubuntu users is that their system is maxing out on memory very easily. Ubuntu borrows unused memory for disk caching, which improves system responsiveness. You’ll find the exact amount under the ‘cache’ label. 

Programs can simply take this cache memory when required, so it’s not limiting the available memory for programs or anything of the sort. There are no downsides to this, aside from the stats being a bit misleading for beginners.

When viewing RAM usage stats, Free indicates memory that isn’t used by anything, while Available indicates how much memory is actually available (including disk caching).

Sometimes, there could actually be faults in your memory subsystem causing high memory usage, or other issues like crashes. We recommend using memtester to stress-test and find any faults in such cases.

sudo apt install memtester 

Use memtester like so

sudo memtester 2048 3

The above command will malloc 2048 MB of memory, and if that’s successful, mlock the memory. Then, it’ll run the tests 3 times. 

If any faults are detected, you’ll need to perform further hardware diagnostic steps to determine what exactly the problem is. It could be bad memory modules or other faulty hardware like CPU or PSU as well.

Additionally, other tests like mprime can be useful if memtest doesn’t detect any faults but you’re still facing unexplained crashes and similar issues on your system.

Anup Thapa

Senior Writer

Anup Thapa is a Linux enthusiast with an extensive background in computer hardware and networking. His goal is to effectively communicate technical concepts in a simplified form understandable by new Linux users. To this end, he mainly writes beginner-friendly tutorials and troubleshooting guides. Outside of work, he enjoys reading up on a range of topics, traveling, working out, and MOBAs.