How To Check RAM On Linux [5 Commands 2024]

Written By Jason Andrews

You need to look into RAM frequently in Linux as insufficient memory makes it slow.

Proper memory utilization is super important to ensure servers are responsive.

Want to check memory (used and free) in your Linux system? You’ve come to the right place.

In this post, I’ll show you the five best commands to view RAM on Linux.

how-to-check-ram-on-linux

Let’s begin!

How To Check RAM Usage On Linux

To check RAM on Linux, you can use commands such as “free”, “top”, “htop”, and “vmstat” or read the “/proc/meminfo” file. These commands will let you check the free and used memory in the system, among other info. The command “dmidecode” can reveal the hardware info of RAM modules.

Random Access Memory or RAM plays a significant role in a Linux operating system-based computer. It helps when the processor runs a program or file to execute operations.

RAM temporarily holds that file or program in its memory until the process is finished.

As Linux is used mainly for servers, looking up available physical memory is essential. It can ensure the servers have enough room to process their tasks and run smoothly without slowing down or becoming unresponsive.

Most of the operations in Linux are done with the command-line, unlike using the GUI in the Windows operating system. The advantage of using command line is that you can make scripts to automate tasks like checking available memory before starting a certain app or process.

If you are a new Linux user, using commands might look like throwing stones in the dark at first. But not to worry, I am here to help you. I will give you the best five ways that might be used to monitor memory in Linux.

Go and check our other article on can I use two different brands of RAM.

Here are the steps to check the memory on Linux:

1. Use The free Command

One of the most popular and simplest commands that most Linux users use to check the RAM is free.

Follow these steps to use the free command:

  • Open your Terminal or Konsole window.
  • Type the following command in the terminal: free.
  • Press Enter.

free

The output is divided into two categories: RAM and Swap. Mem or Memory, is the total amount of installed RAM in your system, and Swap is Virtual Memory.

You will get other information like total, used, free, shared and others.

For better understanding, I will be attaching the meaning of these.

  • total : The amount of actual RAM installed.
  • used : The amount of memory currently used.
  • free : The amount of free memory available.
  • shared : Represents the memory used by tmpfs (Temporary File System) which is a virtual filesystem that appears to be mounted but belongs to volatile memory.
  • buff : Memory in use by the kernel buffers.
  • cache : Memory in use by the page cache where data might be stored first before being written to disk.
  • available : The memory available.

Note: If you want to know the numbers in a human-friendly format, add -h at the end of the free. Or type like this, free -h, which will give the RAM size in gigabytes.

free-h

You can also use this command to get results in your desired format options:

 -b--bytesshow output in bytes
 --kiloshow output in kilobytes
 --megashow output in megabytes
 --gigashow output in gigabytes
 --terashow output in terabytes
 --petashow output in petabytes
-k--kibishow output in kibibytes
-m--mebishow output in mebibytes
-g--gibishow output in gibibytes
 --tebishow output in tebibytes
 --pebishow output in pebibytes
-h--humanshow human-readable output
 --sishow powers of 1000 not 1024
-l--lohishow detailed low and high memory statistics
-t--totalshow total for RAM + swap

Check out our recent article on is ADATA RAM good.

2. Check RAM Usage With The top/htop Command

If you want to check how much memory is used by every process running on the system, then use the top command. Type top and press Enter in your Linux terminal to get the memory each process is using in a detailed view.

Every method above has given you results in text form. But if you want to see the system’s memory usage more visually (in the form of a progress bar), then you can use the htop command.

Since htop is not installed by default on all Linux distributions, you must natively install it in your system. I will demonstrate how to install and use it below.

Follow these steps to use htop command:

  • Open your Terminal window.
  • Type sudo apt install htop in the terminal and hit Enter, and it will ask for your Password to install htop in your system.htop-password
  • Type your Password and press Enter, and this will install the utility.htop-install
  • Type htop and press Enter.htop

As you can see from the image above, the htop utility will show you the memory usage on your Linux system and how much is still available. The command can also show you how many tasks are open and running in the same place.

3. Check RAM Using lshw Command

Another way to check or get information about the RAM is by using the Ishw command, but you have to use the sudo command for this.

Follow these steps to use ishw command:

  • Open your Terminal window.
  • Type sudo lshw in the terminal and hit Enter.

This command will give you more information about your whole computer system like CPU usage. But if you want to only pinpoint the RAM, then use the sudo lshw -short -C memory command.

4. Get RAM information Using meminfo File

In Linux, you can use the grep MemTotal /proc/meminfo command to check RAM size. The file will show the information is saved in the meminfo file in the /proc directory.

The /proc directory contains files referencing dynamic information about the system processes. The meminfo virtual file contains information about the system memory in your Linux operating system.

But beware that this command will show you results in the kilobytes.

Follow these steps to inspect /proc/meminfo file:

  • Open your Terminal.
  • Type grep MemTotal /proc/meminfo in the terminal and press Enter.meminfo

After getting the result, you have to convert them into Gigabytes to find out how much RAM you have. For that, you can use a simple Google search, just like the picture below. [google-convert]

5. Check Virtual Memory Using vmstat Command

The vmstat command provides information on virtual memory usage.

It shows the same information as in the /proc/meminfo file, but many users have faced errors in Linux using this command. So you might want to skip this method.

Follow these steps to use the vmstat command:

  • Open your Terminal window.
  • Type vmstat in the terminal and press Enter.vmstat

You can have difficulty understanding the results. Just like the command free, you will get the same kind of information here but some of them are different from the previous method of checking memory usage. Below you can see the meaning of these headers:

  • r : The amount of runnable processes on your system.
  • b : The amount of processes in uninterruptible sleep.
  • swpd : The amount of RAM currently used by your system.
  • free : The memory available.
  • buff, cache : Buffer memory and memory in use by the page caches.
  • inactive, active : The amount of inactive and active memory.
  • si : The swap used from the disk.
  • so : The swap memory is swapped to the disk.

There are many ways to check your RAM in Linux, but I recommend you use the free, htop, and Ishw commands to check memory.

How To Check Your RAM Type On Linux

You might be interested in knowing the RAM type or the hardware information about the memory modules on your Linux computer. In such an instance, you have to use the dmidecode command.

The dmidecode command might need sudo access to output the result. Running only the dmidecode command will send the output of all the hardware information available to the terminal. So you have to specify the type option as memory.

Here are the steps to list RAM hardware details using the dmidecode command:

  • Open your Terminal window.
  • Type sudo dmidecode –type memory in the terminal.
  • Press Enter.

You will see detailed information about the installed memory modules in your Linux system. It will list the number of physical memory, maximum capacities, DIMM slot positions, DMI type, etc.

Frequently Asked Questions

How Much Is RAM Needed For Linux ubuntu?

You need a minimum of 1 GB RAM, and 4 GB is recommended. However, depending on your work and the purpose of your computer, you might need lots of memory.

How To Check System Specification Linux?

You can use the $ sudo lshw command to find out the specification of your Linux system.

What Is Available Memory Linux?

Available memory means the amount of memory that is not being used at the moment.

Wrapping Up

It is important to be aware of the amount of free and used memory usage on every Linux system.

In a Linux server, it will help you avoid slow response times when you run out of memory.

I have shown you quick and easy ways of checking memory usage in Linux. These commands will work to show the total amount of memory on your system as well as the memory utilization for each process.

If you have any more questions about Linux, feel free to comment below.

About The Author
Jason is a tech fanatic. He got his first computer when he was just 7 years old. Till then he's madly in love with computers, tech, and gaming.Jason completed his post-grad in electrical engineering from a well-reputed university.He's extremely passionate to share his tech findings with 10PCG.

Leave a Comment