How to check memory size in linux

In the Linux system, there are many ways to check the system memory size. Here are a few commonly used methods:

  1. Use the free command

freeThe command can view information such as the total amount, usage, and free amount of system memory. Enter the following command in the terminal to view:

free -h

This command displays memory information in human readable form, for example:

              total        used        free      shared  buff/cache   available
Mem:           7.7G        2.4G        1.1G        1.1G        4.2G        4.3G
Swap:          2.0G          0B        2.0G

Among them, totalrepresents the total amount of memory, usedrepresents the amount of used memory, and freerepresents the amount of free memory.

  1. use the cat command

/proc/meminfoThe file contains detailed information about system memory. You can catview the contents of this file with the command, as follows:

cat /proc/meminfo

This command outputs detailed information about system memory, such as

MemTotal:        8051920 kB
MemFree:         1172128 kB
MemAvailable:    4458368 kB
Buffers:          125528 kB
Cached:          4023852 kB
SwapCached:            0 kB
Active:          2927372 kB
Inactive:        2965436 kB

where, MemTotalrepresents the total amount of memory in kilobytes.

  1. Use the dmidecode command

dmidecodeThe command can display system hardware information, including memory information. Enter the following command in the terminal to view:

sudo dmidecode -t memory

This command will output detailed information of all memory modules in the system, for example:

# dmidecode 3.2
Getting SMBIOS data from sysfs.
SMBIOS 2.7 present.

Handle 0x1000, DMI type 16, 23 bytes
Physical Memory Array
	Location: System Board Or Motherboard
	Use: System Memory
	Error Correction Type: None
	Maximum Capacity: 32 GB
	Error Information Handle: Not Provided
	Number Of Devices: 4

Handle 0x1100, DMI type 17, 34 bytes
Memory Device
	Array Handle: 0x1000
	Error Information Handle: Not Provided
	Total Width: 64 bits
	Data Width: 64 bits
	Size: 8192 MB
	Form Factor: DIMM
	Set: None
	Locator: ChannelA-DIMM0
	Bank Locator: BANK 0
	Type: DDR3
	Type Detail: Synchronous
	Speed: 1600 MT/s
	Manufacturer: Kingston
	Serial Number: 123456789
	Asset Tag: Not Specified
	Part Number: KHX1600C9D3K2/8GX
	Rank: 2
	Configured Clock Speed: 1600 MT/s
	Minimum Voltage: 1.5 V
	Maximum Voltage: 1.5 V
	Configured Voltage: 1.5 V

Where, Maximum Capacityrepresents the total amount of memory in GB.

Guess you like

Origin blog.csdn.net/bulucc/article/details/130204908