How to display memory information in Linux?


The system memory or RAM is an essential part of a computer system. It is used to store the working data and machine code. It is much faster and expensive than the other storage media such as hard disk, CD disk, magnetic tapes, etc.

So knowing about your system’s memory which includes information such as total, free, and used memory, etc can be very helpful in administering the resources of a system.

In this article, we will discuss the different ways to check memory information on a Linux system.

Get memory info using /proc/meminfo

The /proc/meminfo is a file that stores all the information of memory. Many other commands fetch the memory information from this file. We can display the content of this file using one of the following commands in your terminal –

cat /proc/meminfo

or use –

more /proc/meminfo

or you can also use –

less /proc/meminfo

Now you can see the output of this command in the image below –

Find memory info using free command

Free is a command that can be used to display the free and used memory on a Linux system. It shows the statistics of both physical and swap memory.

Now to display the memory info in your terminal use –

free

Or use the following command to see the size of memory in megabytes –

free -m

As you can see in the image above it displays the total, used, free, shared, buff/cache, and available memory.

How to check system memory usage using top command

The top command is one of the most frequently used commands on a Linux or Unix system for administrative tasks. By using this command you can view dynamic and real-time views of processes running in a system.

We can use this command to monitor the memory usage on a system. Now run the following command in your terminal –

top

See the output of this command –

The highlighted part in this image shows the memory information and its usage the size of memory is given in megabytes.

Display virtual memory statistics using vmstat command

The vmstat command in Linux shows the information about processes, memory, paging, block IO, etc. To display the memory usage using vmstat command you need to use option -s with it.

Now execute the following command in your terminal –

vmstat -s

Conclusion

This is how you can check the memory information on a Linux system. Now if you have a query then leave it in the comments below.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.