Меню Рубрики

Check memory linux size

Find Ram Size in Linux Using free And top Commands

Use /proc/meminfo file to find ram size in Linux

Tutorial details
Difficulty Easy (rss)
Root privileges Yes
Requirements None
Time 5m

The /proc/meminfo file tells you about memory usage on the server. This file is used by the free command and many other Linux commands to display the amount of free and used memory (both physical and swap) on the system as well as the shared memory and buffers used by the kernel. Type the following cat command/less command to view total installed ram and used ram, enter:
$ less /proc/meminfo
$ cat /proc/meminfo
Sample outputs:

Of course, we can use the grep command/egrep command as follows to filter out information:

grep MemTotal /proc/meminfo egrep ‘MemTotal|MemFree|MemAvailable’ /proc/meminfo

Use free Command to check RAM size

Free command is a frontend to /proc/meminfo file. It provides more human-readable output to show you the total amount of free and used physical and swap memory in the system, as well as the buffers used by the kernel, run:
$ free -m
$ free -g
Sample outputs:

The free command options

From the free(1) man page:

The -b switch displays the amount of memory in bytes; the -k switch (set by default) displays it in kilobytes; the -m switch displays it in megabytes. The -t switch displays a line containing the totals. The -o switch disables the display of a “buffer adjusted” line. If the -o option is not specified, free subtracts buffer memory from the used memory and adds it to the free memory reported. The -s switch activates continuous polling delay seconds apart. You may actually specify any floating point number for delay, usleep(3) is used for microsecond resolution delay times.

Hence, we try those options too:
$ free
$ free -m
$ free -g -t -o
$ free -t
$ free -o

Finding free and used ram info using the vmstat command

The vmstat command can display memory statistics including additional information about processes, paging, block IO, traps, and cpu activity. Pass the -s option to the vmstat to show us memory statistics as follows:
$ vmstat -s
Sample outputs:

The top Command

The top command provides a dynamic real-time view of a running system including a quick summary information about RAM, CPU as well as a list of tasks currently being managed by the Linux kernel. Type the following command:
$ top
Sample outputs:

Fig.01: Display Linux RAM Size with the top commad

GUI system information tool

The System Monitor Gnome or KDE application enables you to display basic system information and monitor system processes, usage of system resources, and file systems. You can start System Monitor in the following ways:
Click on System menu > Choose Administration > System Monitor
Alternatively, type the following command:
$ gnome-system-monitor
Sample outputs:

Linux view installed memory with the System Monitor application

Say hello to dmidecode Command

The dmidecode command is used for dumping a computer’s DMI (some say SMBIOS) table contents in a human-readable format. This table contains a description of the system’s hardware components, as well as other useful pieces of information such as serial numbers and BIOS revision. Thanks to this table, you can retrieve this information without having to probe for the actual hardware. To see complete information about memory, enter:
$ sudo dmidecode –type memory
Sample outputs:

Related media

This tutorial is also available in a quick video format:

Video 01: 5 Linux Commands: To See Amount Of Free and Used Memory


In this tutorial, you learned how to use the various command line and GUI tools amount of free and used memory in the Linux system. See free and vmstat command man page here and here:
man free
man vmstat
man top
man htop


How to check RAM size?

What is the command to find the RAM size in computer? I want to see result in MB.

4 Answers 4

From a terminal you should be able to use:

-m , –mebi Display the amount of memory in mebibytes.

–mega Display the amount of memory in megabytes. Implies –si .

Open a terminal ( CTRL + ALT + T ).

Run following command to see RAM information in KB (1 KB is equal to 1024 bytes).

Run following command to see RAM information in MB (1 MB is equal to 1024 KB).

Run following command to see RAM information in GB (1 GB is equal to 1024 MB).

Or you can run following command to see more information about the same:

Click on the power/gear icon (System Menu) in the top right corner of the screen and choose About This Computer. You will see the total available memory in GiB. Multiply the value by 1024 to get the size in MiB.

This value (and the value shown as Total in output of free -m on the console), is total physical RAM size, minus the amount assigned to the internal GPU, if your computer has one.

To see the total amount of physical RAM installed, you can run sudo lshw -c memory which will show you each individual bank of RAM you have installed, as well as the total size for the System Memory. This will likely presented as GiB value, which you can again multiply by 1024 to get the MiB value.


4 ways to check the size of physical memory (RAM) in Linux

Published: September 19, 2017 | Modified: June 20, 2020 | 86,684 views

An article explaining how to check physical memory (RAM) in the Linux server. 4 different commands to get memory information from the Linux server.

In this article we will see basic commands to check physical memory on a server in Linux. Many beginners struggle with knowing their system well in context to resources like CPU, Memory, disks, etc. So I decided to write this small article pinpointing commands to check RAM on the Linux server. These commands will work in different flavors of Linux like Red Hat, CentOS, Suse, Ubuntu, Fedora, Debian, etc.

Without much delay lets dive into commands –

1. Using free command

The first command is free. This is the simplest command to check your physical memory. This command is mainly used for checking RAM and SWAP on the system. Using different switch you can change the byte-format of output. Like -b for bytes, -k for kilobytes, -m for megabytes and -g for gigabytes.

Check row with Mem: and number against it. That’s the physical RAM of your server.

In the above output you can see the system is installed with 125GB of physical RAM (observe highlighted rows). By using a different switch -b , -k , -m and -g output changed numbers according to selected byte-format.

2. Using /proc/meminfo file

Another way is to read memory info from the proc filesystem. /proc/meminfo is the file you should read to get detailed information about memory. The very first line or line starts with MemTotal is your total physical memory on the server.

As you can see from output, memory is displayed in kilobytes.

3. Using top command

The famous top command also lists physical memory information in a very clear way. In the upper section of the top command output lies the CPU, Memory, and SWAP information.

I clipped the above section of the top command output in the above example. Check second last line saying Mem: (highlighted row). This shows physical memory in kilobytes. You can see the total, used, and free portions of it. Total is your actual RAM installed on the server.

4. Using vmstat

Another way is to use vmstat (virtual memory stats) command with -s switch. This will list memory in detail with the first-line being total memory on the server.

Memory is displayed in kilobytes by default. The very first line shows you total memory on the server.


5 commands to check memory usage on Linux

Memory Usage

On linux, there are commands for almost everything, because the gui might not be always available. When working on servers only shell access is available and everything has to be done from these commands. So today we shall be checking the commands that can be used to check memory usage on a linux system. Memory include RAM and swap.

It is often important to check memory usage and memory used per process on servers so that resources do not fall short and users are able to access the server. For example a website. If you are running a webserver, then the server must have enough memory to serve the visitors to the site. If not, the site would become very slow or even go down when there is a traffic spike, simply because memory would fall short. Its just like what happens on your desktop PC.

1. free command

The free command is the most simple and easy to use command to check memory usage on linux. Here is a quick example

The m option displays all data in MBs. The total os 7976 MB is the total amount of RAM installed on the system, that is 8GB. The used column shows the amount of RAM that has been used by linux, in this case around 6.4 GB. The output is pretty self explanatory. The catch over here is the cached and buffers column. The second line tells that 4.6 GB is free. This is the free memory in first line added with the buffers and cached amount of memory.

Linux has the habit of caching lots of things for faster performance, so that memory can be freed and used if needed.
The last line is the swap memory, which in this case is lying entirely free.

2. /proc/meminfo

The next way to check memory usage is to read the /proc/meminfo file. Know that the /proc file system does not contain real files. They are rather virtual files that contain dynamic information about the kernel and the system.

Check the values of MemTotal, MemFree, Buffers, Cached, SwapTotal, SwapFree.
They indicate same values of memory usage as the free command.

3. vmstat

The vmstat command with the s option, lays out the memory usage statistics much like the proc command. Here is an example

The top few lines indicate total memory, free memory etc and so on.

4. top command

The top command is generally used to check memory and cpu usage per process. However it also reports total memory usage and can be used to monitor the total RAM usage. The header on output has the required information. Here is a sample output

Check the KiB Mem and KiB Swap lines on the header. They indicate total, used and free amounts of the memory. The buffer and cache information is present here too, like the free command.

5. htop

Similar to the top command, the htop command also shows memory usage along with various other details.

The header on top shows cpu usage along with RAM and swap usage with the corresponding figures.

RAM Information

To find out hardware information about the installed RAM, use the demidecode command. It reports lots of information about the installed RAM memory.

Provided information includes the size (2048MB), type (DDR2) , speed(667 Mhz) etc.


All the above mentioned commands work from the terminal and do not have a gui. When working on a desktop with a gui, it is much easier to use a GUI tool with graphical output. The most common tools are gnome-system-monitor on gnome and
ksysguard on KDE. Both provide resource usage information about cpu, ram, swap and network bandwidth in a graphical and easy to understand visual output.

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected] .

61 thoughts on “ 5 commands to check memory usage on Linux ”

Thanks for informations,
it is very helpfull to see for Linux Lite Versions to see how many ram is used by using small ram older notebooks as example the ideapad 100 modell 14 141I with 2 GB RAM.
So i can s-good ee what i can install better to take the ZorinOS 15, ZorinOS 15 lite or Lubuntu

Thanks for the valuable information..Linux command-line tools to check system memory usage

Anyone can share Linux command to set Cron job and access MySQL.

you can use mysql event for automation , thank me later

It’s very helpful for experienced and beginners

it is a good reference for memory-related commands. thanks for share it.

Use “free -h” for human readable output

Very helpfull for all

i have enough memory in my server(16 go), please tell me how to free buffers/cache memory

free -m
total used free shared buffers cached
Mem: 16052 15958 93 0 68 8858
-/+ buffers/cache: 7030 9021
Swap: 24575 89 24486

swapoff -a && swapon -a

That’s a great article, thank you for the commands.

I’ll definitely use them in order to monitor my RAM.

Any thoughts about memory monitoring using modern solutions such as Prometheus and Grafana?

An excellently written article, This is a good article which offers some helpful information for me, I will read more. I hope we can learn from each other.
E-Learning – Anytime, Anywhere | Automation Laboratories | Noida | Pune

Thanks for sharing useful commands

Great Tutorial.
My Favorite is free- m command I always use this command to check the free memory before deploying a new application on my server.

Very good article found helpful

htop command is really useful
it helped me to solve my server’s over usage problem.
special thanks to Silver Moon!

Thanks for the commands, it is very helpful

Thanks for sharing. Please, can you provide a command to kill a process using a specific port?

netstat -pl | grep “port” ### will retrun pid associated with this port
kill -9 pid ####kill that pid

check out https://github.com/TeoGia/jotun
Its a simple program that outputs heap usage in json format

Great write up, useful on how to read the memory used on the linux system, I also created an easy script to show a summary of free ram in a percentage and also list when you need to worry, i got the idea from the linux ate my ram webpage.

I always use command
> sar -r 1 10
Its shows memory usage for each seconds for 10 seconds. try it.

hi ..
I wanted to find the heap memory usage in a linux machine for every 10sec .. Do you have any command.
If you know any tool which gives graphical representation of Heap memory usage .. that will be more helpful.

I have a question, how to use ram access for each person?

linux working fne with spring boot for developing java application
Spring Boot is the best Java framework for microservices. We recommend you to become an expert at Spring Boot!

It’s really helpful.
Is there any way to monitor memory usage in real time.
Something like a script which checks the memory usage and sending the report to a particular email id in a given interval of time.


Читайте также:  Linux просмотр свободного места на диске

Популярные записи