Memory test commands on Linux

Tram Ho

On linux, there are full commands for almost anything, because the GUI may not always be available. When working on the server, there is only shell access and everything must be done from these commands. So today we will look at the commands that can be used to check memory usage on a linux system. Memory includes RAM and swap.

It is important to regularly check the memory usage and the memory used for each process on the server so that resources are not missing and the user can access the server. For example a website. If you are running a web server, then the server must have enough memory to serve visitors to the site. Otherwise, the site will become very slow or even stop working when there is a spike in traffic, simply because the memory will be reduced. It is like what happens on your desktop.

Free statement

The Free command is the simplest and easiest to use to check memory usage on linux. This is a quick example

Option m shows all data in MB. The total value of 7976 MB is the total amount of RAM installed on the system, ie 8GB. The used column shows the amount of RAM used by linux, in this case about 6.4 GB. The output of this statement is quite easy to understand. What we need to know is cached columns and buffers. The second line tells us that there is 4.6 GB of unused memory. This is free memory in the first line plus buffers and cached .

Linux has a habit of storing many things for faster performance, so that memory can be freed up and used if needed. The last line is swap memory, which in this case is completely free.

  1. The / Proc / meminfo statement The next way to check memory usage is to read the file /Proc/meminfo . The file system / Proc does not contain actual files. They are virtual files containing dynamic information about the kernel and the system.

Check the values ​​of MemTotal, MemFree, Buffers, Cache, SwapTotal, SwapFree. They indicate memory usage values ​​like the free command.

vmstat

The vmstat command with the s option, gives memory usage statistics like the Proc command. Here is an example

The top few lines indicate total memory, free memory, etc.

Command top

The above command is commonly used to check memory and cpu usage for each process. However, it also reports total memory usage and can be used to track total RAM usage. The headers on the output have the necessary information. This is the sample output

Check out the KiB Mem and KiB Swap . They indicate the total, the used part and the free part of the memory. Buffer and buffer information is also present here, just like the free command.

Htop command

Similar to the top command, the htop command also displays memory usage along with many other details.

The header at the top shows cpu usage with RAM and Swap memory usage with corresponding figures.

RAM information

To find hardware information about installed RAM, use the demidecode command. It reports a lot of information about installed RAM.

Information provided includes size (2048MB), type (DDR2), speed (667 Mhz), etc.

Conclude

All the commands mentioned above work from the terminal and have no gui. When working on desktop with gui, using GUI tool with graphical output will be much easier. 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 an intuitive and easy to understand graphic.

Refer

https://www.binarytides.com/linux-command-check-memory-usage/

Share the news now

Source : Viblo