What is the command to check the memory size in linux

02-05-2023

This article introduces the knowledge about the command to check the memory size of Linux. During the operation of the actual case, many people will encounter such a dilemma. Next, let the editor guide you to learn how to deal with it These situations! I hope you read it carefully and learn something!


Linux command to view the memory size: 1. The free command is used to display the system memory status, just execute free -m, and the value of the total item in the output list is the query 2. The cat /proc/meminfo command is used to read and display the content of the /proc/meminfo file, which can display detailed information about the memory. The value of the MemTotal item in the output list is the total memory size of the query.

Linux command to check memory size: free command and cat /proc/meminfo command.

free command

free command is used to display system memory status, including system physical memory, virtual memory (swap swap partition), shared Memory and system cache usage, the output of which is very similar to the memory portion of the top command.

The basic format of the free command is as follows:

[root@localhost ~]# free [options]


Table 1 lists the commonly used options of this command and their meanings.

Table 1 Common options and meanings of free command
OptionsMeaning
-bUse Byte (byte) as the unit to display the memory usage.
-kIn KB as the unit, display the memory usage, this option is the default option of the free command.
-mDisplay memory usage in MB.
-gDisplay memory usage in GB.
-tIn the final result of the output, output the total amount of memory and swap partition.
-onoDisplays the system buffer column.
-s interval secondsContinuously display the memory usage according to the specified interval.

free view memory size -- execute free -m

free -m Show memory usage in MB.

7836.jpg

The free command is used to display the system memory status, including the usage of system physical memory, virtual memory (swap swap partition), shared memory and system cache, its output and top command The memory portion of the is very similar.

free -m command output list, the first line displays the list header information of each column, and their meanings are as follows:

  • total is the total amount of memory;
  • used is the number of used memory;

  • free is free The number of memory;

  • shared is the total number of memory shared by multiple processes;

  • buffers is the number of buffer memory;

  • cached is the number of cache memory.

The Mem line refers to the memory usage; -/buffers/cache The number of memory is equivalent to the used-buffers-cached in the first line. + The number of memory in /buffers/cache is equivalent to free+buffers+cached in the first line; the line of Swap refers to the usage of the swap partition.

It can be seen that the physical memory of the system is 7741 MB, 5623 MB has been used, and 1560 MB is free. The total size of the swap partition is 7935 MB, and 528 MB is currently used.

cat /proc/meminfo command

/proc/meminfoThe file is the main interface to understand the memory usage of the Linux system. Our most commonly used commands such as free and vmstat obtain data through it, and the information contained in /proc/meminfo is much richer than commands such as free.

cat /proc/meminfo to view the linux systemDetailed information about the storage size, you can view the total memory, remaining memory, available memory and other information.



Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us